Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling .exe in VBScript and passing arguments

Status
Not open for further replies.

tgif1

Programmer
Nov 25, 2002
2
US
I am trying to run an executable file within VBScript. I am using the WshShell.Run command to do this but and unsuccessful. I have to pass argument to the executable to run. Sample code:

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run C:\home\robocopy.exe C:\home\test C:\home\test2 /MIR

I have to pass all of the arguments to make the robocopy.exe work. The Run command does not like the arguments and causes an error whenit gets to this point, expexting end of statement error. How can I run the .exe with the argument?
 

Did you try to encompass them with quotes?

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\home\robocopy.exe C:\home\test C:\home\test2 /MIR"


Mark
 
Yes, I tried quotes, parentheses, ampersand symbols, I did ot have any luck with it. The problem is trying to pass the arguments to the .exe file. The WsnShell.Run command is only looking for the .exe file and not the arguments. Is there another command that will do this?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top