Kill and start a program in one batch file

October 13, 2010 at 04:02:28
Specs: Windows 7
Hi , i have a small program running at start.

I would like to have a batch file to turn it off and on.

So, 1: if its running: kill program.exe 2: If its not running: start program.exe

Is it possible to have this in one file, instead of i\using two?.


See More: Kill and start a program in one batch file

Report •

#1
October 13, 2010 at 04:35:07
Thy This.

It may solve your problem. Use Razor's solution at the bottom of the page.

Can I put a question here?


Report •

#2
October 13, 2010 at 04:35:39
:LOL
cls
echo.
echo Enter a processname to find.
echo.
set /p "PROGRAM= > "
for /f "tokens=*" %%j in ('WMIC PROCESS get Caption ^| find "%PROGRAM%"') do goto FOUND
if errorlevel 0 goto NOTFOUND
echo.
echo Press any key to exit.
pause>nul
exit

:NOTFOUND
echo.
echo %PROGRAM% not found.
echo.
start %PROGRAM% (NEED LOCATION)
goto LOL

:FOUND
echo.
echo FOUND: %PROGRAM%
echo.
taskkill /im %PROGRAM%
goto LOL

Happy is ONE who says I am an OttoMAN.


Report •

#3
October 13, 2010 at 07:27:07
Thanks, ive tried the solution example linked:

taskkill /im POPPeeper.exe || start "" "C:\Program Files (x86)\POP Peeper\POPPeeper.exe\POPPeeper.exe"

It works, but not if the program is in the tray (win 7 64bit)

im trying the code from MUs , but i must have edited it wrong since i cant get it to work

edit..
The example didnt have /f but this code worked
taskkill /F /im POPPeeper.exe|| start "" "C:\Program Files (x86)\POP Peeper\POPPeeper.exe"


Report •
Related Solutions


Ask Question