batchfile taskkill /IM cmd.exe not closing cmd.exe

前端 未结 5 2028
小鲜肉
小鲜肉 2021-01-14 17:15

I have a batch file which moves a few files and starts a program and for some reason, after the batch file goes through all the commands in it, it doesn\'t close. The comman

相关标签:
5条回答
  • 2021-01-14 17:41

    You need to "run as admin" to properly call taskkill

    0 讨论(0)
  • 2021-01-14 17:42

    i dont know what u trying to do... but if u wanna exit/close those batch file just used

    :Exit
    exit
    

    if you wanna force close other's application try this commands

    :Exit 
    Taskkill /IM cmd.exe /f /t
    

    Example: ( This just for education purpose only. )

    @echo off`
    . Press continue if you wanna close explorer.exe.
    pause
    Taskkill /IM explorer.exe /f /t
    

    the function will kill task for explorer.exe

    0 讨论(0)
  • 2021-01-14 17:44

    Try start "" "C:\folder1\application1" in both places and remove the taskkill command (or replace it with exit/b if you need to). The extra double quotes are necessary here.

    0 讨论(0)
  • 2021-01-14 17:44

    I recommend using:

    :exit
    exit

    or calling another file which has:

    exit /b which will terminate cmd.exe instead of just the script if it were in the same file.

    i think "exit" will should work fine anyway.

    0 讨论(0)
  • 2021-01-14 17:48

    You can try:

    @echo off
    taskkill /f /im cmd.exe
    :exit
    
    0 讨论(0)
提交回复
热议问题