NisHera
9 years agoValued Contributor
write text file from command prompt
if I run below in TC works fine ...could see cmd prompt restarting server
Sys.OleObject("WScript.Shell").Run("iisreset MyComputer");
if I type below in cmd prompt and manually run it works
iisreset MyComputer >C:\Myfolder\.........\iisRestarted.txt
But if I run below in TC it dosnot work
Sys.OleObject("WScript.Shell").Run("iisreset MyComputer >C:\\Myfolder\\.........\\iisRestarted.txt");
how should I make it works? there are no spaces in file path
Add "cmd /c" at the beginning of your command:
Sys.OleObject("WScript.Shell").Run("cmd /c iisreset MyComputer > C:\\MyFolder\\iisRestarted.txt");
Output redirection is a feature of the command shell (cmd.exe), so you need to run your command via cmd.
Also make sure you run TestComplete as administrator, as required by iisreset.