Hello all. New to the board here. I have not had much experience with scripting and can do very basic tasks but would like to make a script that can defragment, check disk and perform disk cleanup weekly for my users. I have a script that I tried to use but it doesn't seem to work unless defrag and such have reduced their time to seconds. The computers shutdown normally on friday and it is like the script isn't being applied. I have the below script in the Logoff section of the AD Group Policy that is being applied. Any ideas / help would be greatly appreciated, and hopefully through the use of this board I can learn more about scripting and help others! Thanks.

 Code:
; Global PM Script
; SIJ 11/08/08
;
; -------------------------
;
; All Users
SETCONSOLE ("HIDE")

WriteValue ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
NT\CurrentVersion", "RegisteredOwner", "SIJ", "REG_SZ")
WriteValue ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
NT\CurrentVersion", "RegisteredOrganization", "SIJ", "REG_SZ")

WriteValue
("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Active
Setup Temp Folders", "StateFlags0001", "00000002", "REG_DWORD")
WriteValue
("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Compress
old files", "StateFlags0001", "00000002", "REG_DWORD")
WriteValue
("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Content
Indexer Cleaner", "StateFlags0001", "00000002", "REG_DWORD")
WriteValue
("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Downloaded
Program Files", "StateFlags0001", "00000002", "REG_DWORD")
WriteValue
("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Internet
Cache Files", "StateFlags0001", "00000002", "REG_DWORD")
WriteValue
("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Memory
Dump Files", "StateFlags0001", "00000002", "REG_DWORD")
WriteValue
("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Microsoft_Event_Reporting_2.0_Temp_Files",
"StateFlags0001", "00000002", "REG_DWORD")
WriteValue
("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Old
ChkDsk Files", "StateFlags0001", "00000002", "REG_DWORD")
WriteValue
("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Remote
Desktop Cache Files", "StateFlags0001", "00000002", "REG_DWORD")
WriteValue
("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Setup
Log Files", "StateFlags0001", "00000002", "REG_DWORD")
WriteValue
("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary
Files", "StateFlags0001", "00000002", "REG_DWORD")
WriteValue
("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\WebClient
and WebPublisher Cache", "StateFlags0001", "00000002", "REG_DWORD")

IF @Day='Friday'
	RUN "chkdsk.exe C: /F"
	RUN "cleanmgr.exe /dc /sagerun:1"
	RUN "defrag.exe C:"
	RUN "shutdown.exe -s"
ENDIF




Edited by NTDOC (2008-11-21 10:49 PM)
Edit Reason: added CODE TAGS