windows “启动 %comspec% /c script.cmd” vs “启动 cmd /C script.cmd”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8121238/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 08:55:49  来源:igfitidea点击:

"start %comspec% /c script.cmd" vs "start cmd /C script.cmd"

windowsbatch-filecmd

提问by Volodymyr Bezuglyy

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.

我需要 script.cmd 的 cmd 窗口在 script.cmd 完成后自动关闭。

回答by Alex

%comspec%just points to cmd.exe, so both commands will do the same thing. Other than that /Cis correct, this will close the command prompt after execution

%comspec%只指向 cmd.exe,所以两个命令都会做同样的事情。除此之外/C是正确的,这将在执行后关闭命令提示符

回答by Malware Lab

For a not admin user on WindowsXP-SP2.

对于 WindowsXP-SP2 上的非管理员用户。

  • %comspec% starts in %WINDIR%\System32.
  • 'cmd' starts in user's home e.g. C:\Document And Settings\USER1.
  • %comspec% 从 %WINDIR%\System32 开始。
  • 'cmd' 从用户家开始,例如 C:\Document And Settings\USER1。