Passing an argument which includes double quotes to wscript.echo

I regularly use a script to connect to various servers. The script is run in the following manner:

myscript.vbs <TYPE> <SERVERIPADDRESS> <USERNAME> <PASSWORD>

However when the password includes double quotes, they fail to display. This is the code I use to display the username and password:

wscript.echo "Username: " & args.item(2) & "  Password: " & args.item(3)

Without changing the script, is there a way I can pass the double quotes? I've already tried double quote 1, 2 and 3 times, with a preceeding \ and using chr(34). And at best ended up with \ or chr(34) displaying in my popup.
pazza98Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

StealthyDevCommented:
use double-double quote - ""
0
merowingerCommented:
@senthurpandian: does not work
0
pazza98Author Commented:
Then I end up with abcde where I should get "abcde". See below.

---------------------------
Windows Script Host
---------------------------
Username: administrator  Password: abcde
---------------------------
OK  
---------------------------
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

merowingerCommented:
quotes are really the last characters you should use in your password when using wscript.exe or cscript.exe ;)
I get all characters passed to the script..but not quotes!
0
Patrick MatthewsCommented:
Following on merowinger...

If you must allow quotes, I suggest that you designate a particular character/character sequence to stand in for them, and then set up your VBS to do the replacement in code.
0
merowingerCommented:
Exactly e.g This would replace the ~ with a quote

myscript.vbs Username Passw~rd

strPassword = Replace(Wscript.Arguments(1),"~",chr(34))

0
pazza98Author Commented:
However any character or string I might use in replacement,  could also be something I might use in the password. I often don't have a choice about the password and I'm not in a position to change the script. Is what I'm asking impossible?
0
merowingerCommented:
Yes you right and yes it's almost impossible!
You could also input the password by reading it from an textfile. This would work
0
Patrick MatthewsCommented:
Or you can make the sequence for doublequote be more than one character:

strPassword = Replace(Wscript.Arguments(1),"@^~#",chr(34))

While it is conceivable that a user may want to use a tilde in a password, it seems unlikely to me that a user would want to have the characters @^~# as a real sequence in the password :)
0
merowingerCommented:
@matthewspatrick: Bill Gates for sure :P
0
Patrick MatthewsCommented:
:)
0
Psy053Commented:
Why not have the script prompt for the password instead?

strPassword = InputBox("Please enter your password")
wscript.echo "Username: " & args.item(2) & "  Password: " & strPassword

0
pazza98Author Commented:
@Psy053

I think I stated earlier that I'm not in a position to make any changes to the script. Also, the point is to receive an automatic reminder of the password in the popup, not have it entered automatically. In any case it wouldn't be very automatic if I had to type it into a prompt first.
0
merowingerCommented:
I don't see more options, as the less possibilities which we can deliver are furthermore not feasible caused of restrictions on editing the script or changeing the password
0
Patrick MatthewsCommented:
pazza98,

If you want to be able to accommodate " in the password, you are going to have to change the script.  merowinger and I have demonstrated a very, very simple way to do that.

It may not have been the answer you wanted to hear, but it is the right answer.

Patrick
0
pazza98Author Commented:
Without changing the script, is there a way I can pass the double quotes?

Without an answer to this question I can't really award points. There's no point in awarding points to an answer of "there is no way".

Thanks for the suggestions.
0
Patrick MatthewsCommented:
>>Without an answer to this question I can't really award points. There's no point in awarding points to
>>an answer of "there is no way".

Respectfully, I disagree, and so do the EE help pages.  From http://www.experts-exchange.com/help.jsp#hs=29&hi=405


The correct answer to some questions is "You can't do that."        

Sometimes, you will get an answer that isn't what you want to  read, but it still may be the correct answer, and you should award  points to the Expert that gave you that answer.

Patrick
0
AbqBillCommented:
The answerers are correct. The WshArguments object is in charge of reading the script's command-line arguments, and the object always interprets the double quote character (") as an argument delimiter. There is no way to do what you want without modifying the script. Bill.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Patrick MatthewsCommented:
pazza98,

Sorry that we were not able to get a more satisfying answer, and thank you for not holding that against us.  I know what it's like when the correct answer is not what you wanted :(

Patrick
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.