When I execute a VBScript, the command window that it creates closes quickly before the user gets a chance to read the output. How can I get the window to stay open without modifying windows registry?
This is the code:
Set objShell = WScript.CreateObject("WScript.shell")
objShell.Run "SyncToyCmd.exe -R", 1, True
You can send your execution command through the
cmd.execommand interpreter, along with a pause command which will give the user aPress any key to continue . . .prompt to close the window.Or to keep the window alive, use the
/kflag instead of/c:But beware, your VBScript will not continue (or terminate) until this cmd window is manually closed.
The
%comspec%environment variable refers to the correct command to open the command interpreter as per your operating system. On my XP machine, for instance,%comspec%is equal toC:\WINDOWS\system32\cmd.exe.See
cmd.exedocumentation here: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/cmd.mspx?mfr=trueMore info on the use of the
&versus the&&command separators here.