Thursday 27 December 2018

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


I have written a small console program that checks that all my websites are up and running properly. I use the Microsoft Windows Task Scheduler to run this program automatically once a day.


Screenshot


The problem is that, quite naturally, the program steals focus every time it runs. I would prefer if it would start without becoming the top-most window on my desktop. What is the simplest way to achieve this? Of course, I could rewrite my EXE to create a background window (or no window at all), but it would be nice if the Task Scheduler had an option like "Do not steal focus" or something, but maybe that is not even possible...



Answer



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


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...