13
votes

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.

3

3 Answers

19
votes

%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

0
votes

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%

-1
votes

For a not admin user on WindowsXP-SP2.

  • %comspec% starts in %WINDIR%\System32.
  • 'cmd' starts in user's home e.g. C:\Document And Settings\USER1.