• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5673
  • Last Modified:

Setting up a defrag scheduled task via Group Policy

I am trying to figure out how to set up a scheduled defrag task with Group Policy.
I am very new to this, and I am having a great deal of difficulty determining the proper way to do this. I have looked through the knowledge base, but I have not been successful in getting anything to work properly. Im sure it is due to my lack of experience in this area.

The users I have created in AD log on to our Domain, and are placed in the local users group on the PC by default. It appears that I may be having a permission problem when I run the following bat file:

schtasks.exe /create /SC WEEKLY /D Mon /TN defrag /TR "\"C:\windows\system32\defrag.exe\"c: -f" /ST 10:35:00 /SD 04/27/2009 /RU SYSTEM

The scheduled task never gets created via the log on script when the user is in the local users group on the PC.

If I put the word pause at the end of the bat file I get the following error:

C:\>schtasks.exe /create /SC WEEKLY /D Mon /TN defrag /TR "\"C:\windows\system32
\defrag.exe\"c: -f" /ST 10:35:00 /SD 04/27/2009 /RU SYSTEM
INFO: The Schedule Task "defrag" will be created under user name ("NT AUTHORITY\
SYSTEM").
ERROR: Access is denied.

C:\>pause
Press any key to continue . . .

If I move the user to the local admin group, the task gets created and runs with no problems. I am trying not to resort to this to solve this problem.

Should I be looking at a startup/shutdown script instead? If so what considerations do I need to take for computer accounts?

Thank you in advance,

Don
0
dwesolowicz
Asked:
dwesolowicz
1 Solution
 
LauraEHunterMVPCommented:
If you have deployed Group Policy Preferences (GPP), you can deploy this without the use of login scripts:

http://technet.microsoft.com/en-us/library/cc725745.aspx

Deploying GPP requires you to administer Group Policies from a Vista or 2K8 computer, and requires you to deploy the GPP Client-Side Extensions to your XP/2K3 machines. Deploying GPP does -not- require 2008 Active Directory.
0
 
dwesolowiczAuthor Commented:
Sorry for the delay and thank you for the reply.

After doing further research, it appears that you can not run a scheduled task if you are not a local admin on the PC. I also found PsTools at Sysinternals. Within the tools you can run a command called psexec.exe.

This gives you the capability to run defrag via command line on several computers simultaneously.
Since I am a domain admin and running the process from my laptop, I am able to kick off a defrag without getting "access denied".

Thanks again

Don
0

Featured Post

Free tool for managing users' photos in Office 365

Easily upload multiple users’ photos to Office 365. Manage them with an intuitive GUI and use handy built-in cropping and resizing options. Link photos with users based on Azure AD attributes. Free tool!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now