When I run a command such as start "" "file.bat" CMD /C assuming that file.bat does not contain the exit command within, the start command leaves the window previously containing file.bat open. Is there any way to open a batch file in a separate window, but have it behave as if the user personally opened the file?
            Asked
            
        
        
            Active
            
        
            Viewed 54 times
        
    0
            
            
        
        Leo Miao
        
- 7
 - 5
 
- 
                    I'm not sure I understand the issue. Exactly what do you want to happen? You want the new window to close after it's done? – Ben Jan 07 '19 at 23:52
 - 
                    Yes. However, the window does not close unless the exit command was in file.bat, or if the file ran without errors. – Leo Miao Jan 07 '19 at 23:54
 
2 Answers
1
            
            
        This is the reason: start cmd /c "file.bat" works properly.
What does cmd /C mean? - Found through this question.
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.
        Vaibhav Borkar
        
- 73
 - 9