maintenance scripts on workstations

1.

 Maintenance Scripts on Workstations

Get registry settings

First you will need to get the registry settings for diskcleanup to run
Start >> run >> cleanmgr /sageset:11
Tick the boxes as needed and press Ok
Then naviate and export this key
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches]
2.

Remotely deploy the setting to workstations

Save the registry file to a network share and either have a plain text file with all your desktops PCs names in, or do it per machine
psexec \\DesktopPC -u domain\adminaccount -p password regedit /s \\networkshare\registryexport
Do that for a per machine
or
psexec @pcs.txt -u domain\adminaccount -p password regedit /s \\networkshare\registryexport
To use a file with PC names in
Alternatively, you can add the option -i 0 for all of the processes to appear on the current console session
3.

Run other cleanups

We also have CCleaner on our network which also helps clean up the system drive
You can just add ccleaner /auto to your script
4.

Do a defrag

Its always best to run a defrag on a machine to help keep it running smoothly
defrag c:
5.

Put it all into a script

I have created a custom batch script so that I can effectly maintain any machine that I can access on our network
Here is my script
echo off
echo.
echo --- System Maintenance ---
echo.
copy \\ws0450\maintenance\clean.reg c:\windows\clean.reg | echo Copying registry key
regedit /s c:\windows\clean.reg | echo Deploying registry key
cleanmgr /sagerun:11 | echo Disk cleanup is running
echo Disk cleanup finished
"\program files\ccleaner\ccleaner.exe" /auto | echo CCleaner is running
echo CCleaner has finished
echo.
defrag c:
echo.
echo --- System maintance complete ---
echo.
pause
exit
I have also created an interface with VB.net which helps me do this as well
I select an individual workstation, or even the file with names of workstation, then I can run my script on the target machine(s) using admin priviedges
I have found it is better to copy the reg file to their machine first and then import it into the registry
The psexec line my program does is
psexec \\remotepc -u domain\admin -p password -c \\networkshare\CleanUpScript.cmd