I want to build a simple .bat file that after a predetermined set of time (like an hour or so) it will kill a program once's it's started. So say I run the batch file and after 1 hour or so it will kill another program (say firefox)
Asked
Active
Viewed 336 times
-1
-
Do you mean that the other program will be killed, or that the batch program will be killed? – The name's Bob. MS Bob. Feb 06 '15 at 00:58
-
Which operating system (Windows is implied by the '.bat' extension, but not explicit). Can you tell us (or, better yet, show us) what you've tried already? – kdopen Feb 06 '15 at 01:00
-
@kdopen I wasn't sure, so I posted an answer that should work on either DOS or Windows. :b – The name's Bob. MS Bob. Feb 06 '15 at 01:04
2 Answers
0
To make the batch execution pause, you can use a kludge as described in this answer. The 3600 corresponds to 3600 seconds, or one hour.
ping 127.0.0.1 -n 3600 > nul
To kill firefox, you can add a command such as
taskkill /im firefox.exe

Community
- 1
- 1

The name's Bob. MS Bob.
- 859
- 9
- 22
0
dr_andonuts has a standard way or practice I observe many do
An alternative is
batchfile content:
timeout 3600
taskkill /f /im firefox.exe

Community
- 1
- 1

Srinivas Varma
- 56
- 5