How to close the command line window after running a batch file?

后端 未结 7 1005
余生分开走
余生分开走 2020-12-13 08:23

I\'ve got a batch file. After it finished running, i.e. all command lines have been executed, the cmd.exe window stays open. However, I\'d like to have it closed ri

相关标签:
7条回答
  • 2020-12-13 09:01

    For closing cmd window, especially after ending weblogic or JBOSS app servers console with Ctrl+C, I'm using 'call' command instead of 'start' in my batch files. My startWLS.cmd file then looks like:

    call [BEA_HOME]\user_projects\domains\test_domain\startWebLogic.cmd
    

    After Ctrl+C(and 'Y' answer) cmd window is automatically closed.

    0 讨论(0)
  • 2020-12-13 09:10

    Your code is absolutely fine. It just needs "exit 0" for a cleaner exit.

     tncserver.exe C:\Work -p4 -b57600 -r -cFE -tTNC426B
     exit 0
    
    0 讨论(0)
  • 2020-12-13 09:15

    Used this to start Xming, placed the bat file in the Start->Startup directory and now I have xming running on start up.

    start "" "C:\Program Files (x86)\Xming\Xming.exe" -screen 0 -clipboard -multiwindow
    
    0 讨论(0)
  • 2020-12-13 09:17

    I added the start and exit which works. Without both it was not working

    start C:/Anaconda3/Library/bin/pyrcc4.exe -py3 {path}/Resourses.qrc -{path}/Resourses_rc.py
    exit
    
    0 讨论(0)
  • 2020-12-13 09:22

    %Started Program or Command% | taskkill /F /IM cmd.exe

    Example:

    notepad.exe | taskkill /F /IM cmd.exe

    0 讨论(0)
  • 2020-12-13 09:23

    It should close automatically, if it doesn't it means that it is stuck on the first command.

    In your example it should close either automatically (without the exit) or explicitly with the exit. I think the issue is with the first command you are running not returning properly.

    As a work around you can try using

    start "" tncserver.exe C:\Work -p4 -b57600 -r -cFE -tTNC426B
    
    0 讨论(0)
提交回复
热议问题