0
votes

I have made a script to ask for user input and place it in a vbs script to run a program. I am not too far yet, but it gives me an error of Invalid Character. I am not sure what I am doing wrong...

   ' "strIP" is the IP address entered by the user
strIP = InputBox("Please enter the IP address of the Access Point")
   ' "strUser" is the Username entered by the user
strUser = InputBox("Please enter the Username of the Access Point")
   ' "strPass" is the Password entered by the user
strPass = InputBox("Please enter the Password of the Access Point")

Set objShell = WScript.CreateObject("WScript.Shell")

   ' Command to run Plink with the user input data provided.
Plink = "C:/Program Files (x86)/plink/plink.exe"
sPlinkOptions = " -ssh -pw"
sCommand = """" & Plink & sPlinkOptions & strPass & """ """ & strUser & ""@"" & strIP
objShell.Exec(sCommand)

I am sure my mistake is the last line, but I am still getting my feet wet and am not sure. I am essentially trying to run a bat command that received its variables from a VBscript and didn't want to make 2 separate files to do so.

1
Add: "WScript.Echo sCommand" (no quotes) and comment out the last line. That will print the sCommand line you built to the console so you can see it - maybe that will show you what is wrong.Jen R
tried that, the error is in line 13 the assignment to sCommand, not the execPaxic

1 Answers

0
votes

The issue is with the quotes, depends on the output you want. Try something like :

sCommand = """" & Plink & sPlinkOptions & " " & strPass & " " & strUser & "@" & strIP & """"
wscript.echo sCommand

"C:/Program Files (x86)/plink/plink.exe -ssh -pw password [email protected]"

The interpreter did not like the quotes around the @ sign. ""@"" is not valid. """@""" would have worked in.