Forum Discussion
var obj = Sys.OleObject("WScript.Shell");
obj.Run("\"" + strMyPath + "\"");
It works wonderfully.
i had the same problem using the example from Allan (The system cannot find the file specified), and tried the suggested change from jsmunroe, which worked, but I’m relatively new to coding and don't understand why my original path in mypath didn't work, and why the one from jsmunroe did.
Therefore, why does inserting additional "\"'s on either side of the path correct the problem?
var obj = Sys.OleObject("WScript.Shell");
var mypath = "C:\\PixelPOS\\TestComplete\\Default INI and Policies\\XMLPolicies Reset.bat"
obj.Run("\"" + mypath + "\"");
- AlexKaras10 years agoChampion Level 3
Hi,
This is because the path to your .bat file contains spaces ("C:\\PixelPOS\\TestComplete\\Default INI and Policies\\XMLPolicies Reset.bat") and without quotes the system looks for the "C:\\PixelPOS\\TestComplete\\Default INI" file that, obviously, does not exist.
To get a visual illustration of the said above:) try to type
C:\\PixelPOS\\TestComplete\\Default INI and Policies\\XMLPolicies Reset.bat
in the command prompt, press Enter and check the result. Then type
"C:\\PixelPOS\\TestComplete\\Default INI and Policies\\XMLPolicies Reset.bat"
press Enter and check the result one more time.
- srini_molleti8 years agoNew Contributor
Hi Martin,
Could you please help me similar command with command line arguments. I mean of I need to pass arguments while running the bat script.
Thanks for your help in advance.