Click here to Skip to main content
15,891,567 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How can I make a bat file stop working after it has been clicked so after 15 min it doesn't work forever?

Is this possible?
Posted
Comments
Maciej Los 29-Nov-13 18:58pm    
What that bat does? (code, please).
Sergey Alexandrovich Kryukov 29-Nov-13 19:27pm    
It should not matter, only see my comment below.
As to the answers: please pay attention: I think we have a winner (Solution 1).
—SA
Sergey Alexandrovich Kryukov 29-Nov-13 19:25pm    
Why? It would be much better to create a batch which do all the work and terminates itself on proper condition, or develop some "real" application...
—SA
Maciej Los 30-Nov-13 11:45am    
Agree!
Braydon 4-Dec-13 0:17am    
This is for a key logger for my employees I want to see what they type in 5 min so that is why I developed this.

Anyway I make all sorts of stuff VB apps, Web Apps, Computer OS's (WORKING ON IT), ECT.

1 solution

@echo off
:loop
start yourtarget.exe ...
timeout /t 1200 >null
taskkill /f /im yourtarget.exe >nul
goto loop


This will restart your program every 20 minutes.

I think I will elaborate on what it does and how you can edit it.
The key part is the "timeout" function witch is standard EXE in system32. The 1200 is the seconds. By changing that it will change the amount of seconds to wait before killing the process and starting it back up again.
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 29-Nov-13 19:24pm    
Very good, a 5... :-)
—SA
[no name] 29-Nov-13 20:03pm    
thanks
Maciej Los 30-Nov-13 11:44am    
As Sergey had mentioned: You're a winner!
+5!
Braydon 4-Dec-13 0:18am    
Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900