Forum Discussion
Hi Jordan,
There is a couple of ways to do that:
1. You can add your batch file as a TestedApps item.
2. Run you batch file from the script:Sub Test
Set obj = Sys.OleObject("WScript.Shell")
obj.Run("c:\test.bat")
End Sub- jsmunroeNew ContributorThe solution was to enclose my path in quotes so I had to do something like this. This is javascript, I apologize.
var obj = Sys.OleObject("WScript.Shell");
obj.Run("\"" + strMyPath + "\"");
It works wonderfully.- martin_facchiniContributor
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 + "\"");- AlexKarasChampion 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.
- jsmunroeNew ContributorThanks for your response. The second open worked best as this is a batch file that may or may not exist in a folder. Though the FSO says the batch file exists I get the following exception:
The system cannot find the file specified.
Related Content
- 9 years ago
Recent Discussions
- 12 hours ago
- 13 hours ago