How to make a scheduled window-creating program not steal the focus?

Solution 1:

You could have Task Scheduler run a vbscript that opens your console program. The vbscript can use the Shell Run method to open it minimized with something like:

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "notepad.exe", 6, true

There is some basic info about this at http://ss64.com/vb/run.html

Solution 2:

Don't call the application directly. Run it from a shortcut that starts minimized.

I suppose you could also add a batch file into the mix that uses /start /min for the same effect, but I suspect the batch file will steal focus unless it is called from a shortcut that starts minimized.

EDIT: The start /min does steal focus very briefly, but it works on my machine, using a .cmd batch file that calls a new Command Line window (using cmd.exe).

My batch file looks like this:

@echo off
cls
start /min C:\Users\Randolph\Desktop\shortcut.lnk

The shortcut itself opens cmd.exe and has default options selected, except that it opens minimized (the option Run: is set to Minimized).