启动命令不断创建额外的窗口

时间:2019-01-07 23:25:41

标签: batch-file

当我运行诸如start "" "file.bat" CMD /C之类的命令时,假设file.bat中不包含exit命令,那么start命令将使先前包含file.bat的窗口保持打开状态。有什么方法可以在单独的窗口中打开批处理文件,但是它的行为就像用户亲自打开文件一样?

2 个答案:

答案 0 :(得分:2)

只需稍微不同地调用您的命令即可:

start cmd /c "file.bat"

答案 1 :(得分:1)

原因是:启动cmd / c“ file.bat”正常。
  What does cmd /C mean?-通过此问题找到。

cmd /?
    Starts a new instance of the Windows XP command interpreter

 CMD [/A | /U] [/Q] [/D] [/E:ON | /E:OFF] [/F:ON | /F:OFF] [/V:ON |
 /V:OFF] [[/S] [/C | /K] string]

 /C      Carries out the command specified by string and then
 terminates

 /K      Carries out the command specified by string but remains

 /S      Modifies the treatment of string after /C or /K (see below)

 /Q      Turns echo off

 /D      Disable execution of AutoRun commands from registry (see
 below)

 /A      Causes the output of internal commands to a pipe or file to be
 ANSI

 /U      Causes the output of internal commands to a pipe or file to be
         Unicode

 /T:fg   Sets the foreground/background colors (see COLOR /? for more
 info)

 /E:ON   Enable command extensions (see below)

 /E:OFF  Disable command extensions (see below)

 /F:ON   Enable file and directory name completion characters (see
 below)

 /F:OFF  Disable file and directory name completion characters (see
 below)

 /V:ON   Enable delayed environment variable expansion using ! as the
         delimiter. For example, /V:ON would allow !var! to expand the
         variable var at execution time.  The var syntax expands variables
         at input time, which is quite a different thing when inside of a FOR
         loop.

 /V:OFF  Disable delayed environment expansion.