Tuesday 19 October 2010

Windows Task Scheduler - running more often than every 5 minutes

The problem - I wanted to interrogate a network of temperature sensors every two minutes. Not too difficult to do it once, and to package that into a bat file. But how could I run the bat file every two minutes when Windows Task Scheduler offers nothing more frequent than "every 5 minutes"?

The answer - stop respecting authority (in the shape of the options provided) and get assertive. If you want to run the program every 1 minute,  type in "1 minute" into the selection box. 

And it works! at least for me (Windows 7 Pro 64-bit).

* * *

NB - to make the BAT file run invisibly without having to install Visual Basic:

Save the following line as invisible.vbs (use Notepad Save As... All Files)

CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False

Confirm you have Scripting installed (By typing wscript in the Start Run dialog) 

Use the following as the script to call from Task Scheduler (Replace the "MySubFolder" with your file paths)

wscript "C:\MySubfolder\invisible.vbs" "C:\MySubfolder\MyBatchFile.bat"

Thanks to kimsland at http://forums.techguy.org

2 comments:

kimsland said...

Thanks John, good post ;)

chaukeedaar said...

Was looking for the exact information and thought I would have to edit the registry ;-)
"stop respecting authority" - I like that liberating approach a lot - god job, thanks :-)