Question Locked

Defrag on shutdown with .bat file

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Anyone running shutdown scripts from Group Policy? "gpedit.msc" - windows settings - scripts - shutdown - add shutdown.bat. My "shutdown.bat" reads.

cleanmgr /sagerun:11
defrag -v c:\
exit

It is obvious that it runs. Takes a while to finishing "running shutdown scripts".

Thing is, If after you boot up the computer and go into windows defrag, it graphically shows the same as it did before,(lots of red) and states "you should defrag this drive"

Even if you do it from a command line, same results...
Then I run it with the windows defrag program, and it defrags nicely.

Is running defrag from the command line really working?

3 replies

by nimmo

Try adding the -w flag and see what happens, if its a shutdown script I dont see the need for verbose mode to be enabled so I'd remove that once the script is working properly.

Also you may want to try running it without the cleanup manager to see if thats whats holding the script up.

by rob miners

No its not.
You have the wrong syntax defrag -v c:\

Try it this way defrag c: -v or better still defrag c: -f

< trying to time sinc >

This discussion is closed to new replies.