Question Locked

Scripts

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
How do I create a script that pushes from a server to user computers that defrags, disk cleans, and check disk? I have never written something like this before and I have no idea where to start? Is there an easier way to do this with out going to each computer and doing it separately?

2 replies

by scott_heath

use schtasks to schedule the tasks. chkdsk requires a reboot to run after setting the dirty bit on the drive.

Here is a bat file I used:

:: Delete All Tasks
schtasks /delete /tn * /f

:: Recreate Orginal Tasks with New Schedule and Run As System Account
schtasks /create /ru "System" /sc weekly /st 04:00:00 /tn "Reboot" /tr "shutdown -r -t 0"
schtasks /create /ru "System" /sc monthly /mo first /d mon /st 03:55:00 /tn "SetDirtyBit" /tr "fsutil dirty set c:"
schtasks /create /ru "System" /sc monthly /mo first /d mon /st 04:30:00 /tn "SetDefrag" /tr "c:\windows\system32\defrag.exe c: -f"

This discussion is closed to new replies.