Batch file start命令继续创建额外的窗口

Batch file start命令继续创建额外的窗口,batch-file,Batch File,当我运行诸如start”““file.bat”CMD/C之类的命令时,假设file.bat中不包含exit命令,则start命令会使以前包含file.bat的窗口保持打开状态。是否有任何方法可以在单独的窗口中打开批处理文件,但它的行为却好像用户亲自打开了文件一样?只需稍微不同地调用您的命令即可: start cmd /c "file.bat" 只需稍微不同地调用您的命令: start cmd /c "file.bat" 这就是原因:start cmd/c“file.bat”工作正常。 -通过

当我运行诸如
start”““file.bat”CMD/C之类的命令时,假设file.bat中不包含
exit
命令,则start命令会使以前包含file.bat的窗口保持打开状态。是否有任何方法可以在单独的窗口中打开批处理文件,但它的行为却好像用户亲自打开了文件一样?

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

start cmd /c "file.bat"

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

start cmd /c "file.bat"

这就是原因:start cmd/c“file.bat”工作正常。
-通过这个问题找到了答案

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.

这就是原因:start cmd/c“file.bat”工作正常。
-通过这个问题找到了答案

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.

我不确定我是否理解这个问题。你到底想发生什么?你想让新窗口在完成后关闭吗?是的。但是,除非退出命令在file.bat中,或者文件运行时没有错误,否则窗口不会关闭。我不确定我是否理解这个问题。你到底想发生什么?你想让新窗口在完成后关闭吗?是的。但是,除非exit命令位于file.bat中,或者文件运行时没有错误,否则窗口不会关闭。