Using Group Policy to defrag XP PC's- Scrpits, Batch files??

By jshoemaker21 ·
I need a script or batch file I can push out using Group Policy. Any ideas. Please help Thanks

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Collapse -

I have been working on this too

by Dumphrey In reply to Using Group Policy to def ...

and the problem I keep bumping into is permissions. Defragging requres at least poweruser and I refuse to give peeps that permission unless required.

a simple batch file with
defrag c:
will do the job if the logged in user has permissions, or you can use a batch file on the local machine to contact the remote machine using the sysinternal psexec command, but this requires a deal of time and a single admin password on each machine. If I could find a way to make the command start the crocess and then move on, I would be happy, as it is, it waits for the spawned process to finish befor starting on the next itteration.
I just reread the psexec command settings
psexec \\MachineName -s -d defrag c:
will start a defrag session on the remote machine, running it under the system account, and then return control of the shell to the batch/user. I need to test if it leaves the spawned process running on the remote machine.

for /f %%a in (c:\list.txt) do psexec -s -d \\%%a defrag c: && shutdown -s -f
in a batch file will read each successive entry in list.txt, spawn a terminal session, run defrag c: and then shutdown the box. In theory. I have only partialy tested this.
List.txt should be a list of machine names or ip address you want to defrag and shutdown.

Collapse -

Push using GP

by jshoemaker21 In reply to I have been working on th ...

I had a script in the past that worked using GP. I cannot find it though.

Collapse -

I edited my previous answer

by Dumphrey In reply to Push using GP

and it has a code snippit that works. You can push out scripts that run as system accounts through GP. This is almost as easy, and can be scheduled to run on Friday nights late. I would be interested to find a GPO to defrag machines.

This script will not work on 2000, just XP and above.

Collapse -

Could you send the whole script?

by jshoemaker21 In reply to I edited my previous answ ...

THen just save as a .vbs?

Collapse -

The script is

by Dumphrey In reply to Could you send the whole ...

for /f %%a in (c:\list.txt) do psexec -s -d \\%%a defrag c: && shutdown -s -f

Save this as a .bat file. Download psexec from sysinternals
Create a directory on your desktop, put the extracted psexec.exe and you .bat file in this directory. Create a list of machine names you want to defrag, an AD dsquery output or manual list creation. Name this file list.txt. Double click .bat file or add it to scheduled tasks for later in evening. Let me double check my dsquery command to get machine names. I will edit this and add the command.

Collapse -


by jshoemaker21 In reply to The script is

I appreciate it but I was looking for the script I had that I can just link to a GPO...

Collapse -


by Dumphrey In reply to ...

I have found this to be more flexable though, as you can only set GPO script for logon or logoff. I can run this at midnight on saturday one one group and 2 am on friday on another etc..
I do understand why you want a gpo script for management. And I am looking for one as well, but so far all I can find is a gpo plug-in for Diskeeper, but it requires Diskeeper to be installed on each workstation.

Collapse -

Logoff Script

by jshoemaker21 In reply to The script is

I did have one that worked when a user shut down. That's what I'm looking for, just something to make a gpo that runs the logoff scrpit and rund defrag at shutdown.

Collapse -

And as always I hit the same wall

by Dumphrey In reply to Logoff Script

of supplying appropriate permissions to run the script as a GPO. =\ Hence my workaround. I will keep digging this after noon and see if I can find any VB to do the trick.

Collapse -


by jshoemaker21 In reply to The script is

I appreciate it. I will too.

Related Discussions

Related Forums