How might I go about limiting the execution time of a command line program in windows? I know in linux there is timeout/timelimit available, but I have been unable to find similar utilities for windows.
|
migrated from stackoverflow.com Dec 17 '12 at 16:46
If you put this in notepad and save it as I have used 10 seconds as an example, just tweak to your needs. Also, if you are using Vista or above you can scrap the
|
|||||||
|
|
As I know there seems no such a function exist, but I think it's doable if you make it run as a windows task via Task Scheduler, from there you can set a limitation of execution, the setting named as: Stop the task if it runs longer than:, you can get more detail from here: http://technet.microsoft.com/en-us/library/cc722178.aspx |
|||
|
|
|
If you can be bothered with using PowerShell:
Either If you prefer a cmd solution that will only call PowerShell to start the process and then store it's PID in a variable:
|
|||
|
|