What is the difference between following commands:
start %comspec% /c script.cmd
start cmd /C script.cmd
I need that cmd window for script.cmd should close automatically when script.cmd is finished.
%comspec%
just points to cmd.exe, so both commands will do the same thing. Other than that /C
is correct, this will close the command prompt after execution
The difference is that "%comspec%" should expand to the default command interpreter, whereas "cmd" searches for a cmd executable and invokes it. Most of the time they are the same.
But in case there is a cmd executable (cmd.exe, cmd.bat, etc) in the current directory, than that cmd executable will be invoked.
I would go with using %comspec%
For a not admin user on WindowsXP-SP2.
%comspec%
is defined with an absolute path to cmd.exe, cmd
simply search in all parts of the path variable and in your case you have a cmd.exe also in C:\Document And Settings\USER1
but this shouldn't be the standard