Opening/Closing application via .bat file [Windows]

Edmhar picture Edmhar · Mar 16, 2016 · Viewed 70.6k times · Source

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 thought when the app opens it will not execute the remaining commands unless I manually close the app.

Here is my code:

cd "C:\Program Files (x86)\Aspera\Point-to-Point\bin\"
asperascp.exe
sleep 5 
taskkill /IM asperascp.exe /f

I also try removing the sleep command.

cd "C:\Program Files (x86)\Aspera\Point-to-Point\bin\"
asperascp.exe
taskkill /IM asperascp.exe /f

But it will have same output it will not execute the remaining commands when the asperascp.exe starts.

Any tips?

Thanks.

Answer

Hackoo picture Hackoo · Mar 16, 2016

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