Run command in VBScript

I want to pass the working directory into the Run command in VBScript like this: 

Code: vbscript
  1. <div>Set s = CreateObject ("WScript.Shell")
  2. s.Run Chr(34)&amp;"k:\SAMURAI WARRIORS 2\SW2.exe"&amp;Chr(34)&amp;" "&amp;Chr(34)&amp;"k:\SAMURAI WARRIORS 2"&amp;Chr(34)</div>

but it doesn't work. Would someone help me, please? Thanks!

8,698 views 3 replies
Reply #1 Top

Why don't you just create a shortcut that runs samurai warrior s 2 the way you want it and then just run that shortcut with your script?

Reply #2 Top

Well Chr(34) = ", so in effect you're asking your script to execute ""k:\SAMURAI WARRIOS 2\SW2.exe" & " & "k:\SAMURAI WARRIORS 2" & "

I believe command line doesn't require quotations to execute a program.

Reply #3 Top

Thanks for your replies!

Quoting BigDogBigFeet, reply 1
Why don't you just create a shortcut that runs samurai warrior s 2 the way you want it and then just run that shortcut with your script?
End of BigDogBigFeet's quote

If it's too difficult or impossible to pass the working directory into run command, your solution is the only one for me to go. 

Quoting roflmfaoo, reply 2
Well Chr(34) = ", so in effect you're asking your script to execute ""k:\SAMURAI WARRIOS 2\SW2.exe" & " & "k:\SAMURAI WARRIORS 2" & "

I believe command line doesn't require quotations to execute a program.
End of roflmfaoo's quote

Without quotations, you can run a program whose path doesn't contain spaces in it. If your path contains spaces, you have to use quotations or you'll get invalid path errors because Windows considers space as a delimiter between the program and its parameters.

 

In general, I just want to know how to pass the working directory as a parameter into Run command in VBScript because some games require this parameter (working directory) to run, I have searched around without answer. It seems this is impossible. So, BigDogBigFeet has the answer for me.

Thanks a lot, again, guys!