Opening/Closing application via .bat file [Windows]

前端 未结 2 1045
慢半拍i
慢半拍i 2021-02-08 06:00

Good Day, I have a .bat file that run a specific application then after 5 seconds it will close/kill it.

I having right now due to it successfully open the application t

相关标签:
2条回答
  • 2021-02-08 06:17

    You can use Start /b command.

    @echo off
    cd "C:\Program Files (x86)\Aspera\Point-to-Point\bin\"
    Start "" /b asperascp.exe 
    timeout /T 5 /nobreak >nul
    taskkill /IM asperascp.exe /F
    
    0 讨论(0)
  • 2021-02-08 06:34

    TASKKILL /IM asperascp.exe /F
    will kill all images with the same image name. So if you run the same program twice, for example, and the second one starts before the first one exits, the second one will be killed too when the first one runs taskkill. If you do tasklist you will see some images with the same image name, but with differing PIDs. You will have to get the PID of the process started by your batch file (I can't think of how to do this with CMD.) Then you can use: TASKKILL /PID 999 /F

    0 讨论(0)
提交回复
热议问题