aa1
6 years agoContributor
Run a bat file from network does not work
Hi,
I am trying to use wshshell to run a bat file from cmd but somehow I cannot get it right. All I am doing is do a cd\ on the cmd to get back to local and then browse the network path. Do I need to map it to local drive? Please help!
var path = "\\\abc.local\\def\\Clickonce\\AB\\stg\\xyz.temp.Desktop.application"; var WshShell = new ActiveXObject("WScript.Shell"); WshShell.Run("cmd /K cd\\" & "cmd /K" + path); Delay(10000);
The error just says:
JScript runtime error.
The system cannot find the file specified
The system cannot find the file specified
Thank you in advance,
aa
Rather than use "CD", set the CurrentDirectory property on the WshShell object.
For that matter... you don't need to instantiate the shell object... TestComplete provides a wrapper. I don't think, either, that you need to use the CMD /K anywhere in this... you just need to indicate the batch file to run... which is, I assum, the contents of the "path" variable.
var path = "\\\abc.local\\def\\Clickonce\\AB\\stg\\xyz.temp.Desktop.application"; WshShell.CurrentDirectory = "C:\\" //Or whatever you want your root to be WshShell.Run(path); Delay(10000);