View Full Version : Creating Scheduled Tasks Remotely

26-10-2005, 11:29 AM

I am trying to roll out some basic scheduled tasks to our domain of Windows 2000 and XP Computers.

I want to be able to put a string into the user's login script (or create an Altiris job to roll them out) that will setup a scheduled task and run every night for basic things like Disk Cleanup and Defrag etc.. I have setup a Disk Cleanup with a template of the things I want cleaned out, and exported the registry file for those settings. That’s all working fine on my PC etc. But when I try to write the command line to create the scheduled task I run into problems. This is what I have so far:

schtasks /create /tn "Daily Disk Cleanup" /tr "cleanmgr.exe /sagerun:13" /ru administrator /rp password /sc daily /st 15:30:00

So this is supposed to create a task called "Daily Disk Cleanup" that runs "Cleanmgr.exe with my set template (called 13) running as the local administrator with the local password every day at 3.30pm... Of course before I run this I have merged the Reg Key of the sagerun template

I have tried MANY different combinations with help from Microsoft’s website below with no luck:


Could someone please help me out here? I have spent too long on something that should be EASY! Or maybe I'm just stupid...



26-10-2005, 12:16 PM
Are there any error messages?

26-10-2005, 01:46 PM
AHH sorry guys, i got it working with the above script only i cant use Disk Cleanup without providing the currently logged on user's password. Because i'm running it as the local administrator, its only clearing out the local admins Temp files etc...

I will just write a BAT file to clear out whatever files i need...

Ohh and the above command only works on XP! (the schtasks command) Now i have to figure out how to do it for 2k! Any ideas?? :)

27-10-2005, 10:25 PM
Doesn't it just create a .job file? I think it might include the credentials in the file or else you have to add them using a text editor, but it can definately be done. You could just copy the .job file into the appropriate location and viola.