scheduled tasks and .net
Sat, Jul 16, 2005This week has been rather hectic, we're finalizing a software release at work and its crunch time. While working on our installer I realized that the scheduled tasks we wanted to add did not have passwords associated. Without passwords the tasks will not run, which is a very bad thing for us. Apparently there is a command line scheduled task manager (XP/2k3 only). While I apparently could have chosen to hex edit the XP binary to run on 2000, I'm glad that I didn't. I don't think that redistributing modified copies of OS files is necessarily a good idea when dealing with production software. Instead I chose to seek out a programmatic solution. I started out looking for an scheduled tasks automation object to be used from vbscript, which as it turns out does not exist across 2000+. I did find a COM wrapper library for use with .net projects (music to my ears), which worked wonderfully. I now have a simple command line tool to register and delete scheduled tasks, which I can call from my installer.
While I was searching for programmatic solutions to my problem, I ran across the WMI task scheduler interface which does allow you to create and delete tasks. Though the interface does not seem to provide a means for running the task as a user other than LocalSystem or NetworkHost, which invalidated it as a possible solution for my problem.
In addition to all of that I have learned the true meaning behind the phrase Begging the question.