Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scheduled Tasks-using login script?

Status
Not open for further replies.

dhscott

IS-IT--Management
Jan 7, 2004
22
0
0
US
I'm trying to schedule an automatic defrag using scheduled tasks on all user machines. All user machines are windows xp. I am able to create a task using "c:\windows\system32\defrag.exe c: /f" command in a login script. It creates the task ok, but it doesn't run. I think it's a permissions thing, when you look at the task on a user machine, the Run As field is blank. Is there a way to make it run as the user or the administrator? The users are local admins (they have to be because of another program we use).

Is this the best way to do this, is there a group policy that would be better?

Any suggestions would be much appreciated.

Thanks
 
The Task Scheduler allows the use of alternate credentials. It also includes as a scheduled time the run of a defined job at start and at logon.

Rather than call the defragger in the logon script, create a scheduled task to run under the local machine Administrator username and password.

I must confess that if someone set up my machine to defrag at every Start I would remove the task. There is no cause to defragment this often. Disk cleanup, though, is a good idea and is easy scheduled with the "sageset" feature. See Sharon Crawford's discussion here:
 
Also, the Win2k resource kit utility "WinAT" should be used in your logon if attempting to schedule a task from the command line:
This will allow you to pass local Administrator credentials and make a true Scheduled Tasks job entry from the command line.
 
Hi bcastner
If I don't use a logon script, how do I create the task on all of the user machines?
And how do I do it as the local Admin?

I know how to create it locally, but I have over 130 machines, so I'm trying to automate the process.

I don't want to run it at logon, but want to schedule it to run like once every month or two. I can schedule the task for when I want (that's not a problem) using the AT command in a login script, but I can't get it to use the correct credentials, so it doesn't run.

Any other thoughts?
Thanks
 
The best way to handle this is to use the native XP utility Schtasks.exe. Rather than "push" the task through the logon script, schtasks allows you to remotely "push" a Scheduled Task to your workstations. It also allows you to modify the scheduled task job parameters.

Note carefully the syntax of the command. You use the /s and /u parameters to specify the remote computer: [/s computer [/u [domain\]user /p password]

I keep a listing of my workstations as single entries and just modify the values within notepad as a .CMD file for exactly this reason.

 
Thanks bcastner, that worked great!
We're rolling it out today :)

I am now trying to add Disk Cleanup as a scheduled task. I can create the scheduled task ok, and I get it to run ok using cleanmgr.exe /sagerun:n , but is there a way to run it in the background, hidden from the users? Or at least have it run minimized?
Also, when you run cleanmgr.exe /sageset:n it saves those settings in the registry, any idea where?

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top