gNome
asked on
DOS script to kill if .bat file takes longer than 5 minutes to run
I have a simple script that calls an executable and I need to wrap a timeout around the process so that the process ends if it takes longer than 5 minutes to run. I need to do it procedurally within the bat file without the schedule task option.e.g.
If I call myscript.bat and it takes longer than 5 minutes to execute - kill the running process. Is there simple vbs that would allow me to manage the time it shoudl take to run the script?
If I call myscript.bat and it takes longer than 5 minutes to execute - kill the running process. Is there simple vbs that would allow me to manage the time it shoudl take to run the script?
its simple....
make a script like this..
then u may get 300 seconds of waiting time that is 5 min...
after this time the executable will end process!!!
make a script like this..
then u may get 300 seconds of waiting time that is 5 min...
after this time the executable will end process!!!
myscript.exe
sleep 300
kill myscript.exe
pause
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Mani's script will not work, because when a batch file calls an executable it waits for the executable to return before continuing.
TakedaT is on the right track, I used to use VBS in WSH files on windows almost exclusively and had gotten quite adept at using the execution command to run DOS commands but due to the need to run more of them I am now mainly a batch writer, I'll see fi I can find an old script, something says that there is a bit more you'll want to do than his 5 lines of code..
TakedaT is on the right track, I used to use VBS in WSH files on windows almost exclusively and had gotten quite adept at using the execution command to run DOS commands but due to the need to run more of them I am now mainly a batch writer, I'll see fi I can find an old script, something says that there is a bit more you'll want to do than his 5 lines of code..
ASKER
Excellent solution - thanks!
http://technet.microsoft.com/en-us/library/cc507860.aspx