Monthly defrag and reboot - Printable Version +- Linux-Noob Forums (https://www.linux-noob.com/forums) +-- Forum: Windows Noob (https://www.linux-noob.com/forums/forum-5.html) +--- Forum: How Do I? (https://www.linux-noob.com/forums/forum-70.html) +--- Thread: Monthly defrag and reboot (/thread-3920.html) |
Monthly defrag and reboot - Digerati - 2003-12-17 I am thinking about scheduling a batch script I wrote to defrag these win2k machines and then reboot them on the first day of each month at the stroke of midnight. Anyone have any opinions on this? Here is the batch file to reboot everyone if they are connected to the network and are up and running. @ECHO OFF Ping 2202|Find "TTL=128">NUL IF NOT ERRORLEVEL 1 GOTO REBOOT1 Ping 2203|Find "TTL=128">NUL IF NOT ERRORLEVEL 1 GOTO REBOOT2 Ping 2204|Find "TTL=128">NUL IF NOT ERRORLEVEL 1 GOTO REBOOT3 Ping 2205|Find "TTL=128">NUL IF NOT ERRORLEVEL 1 GOTO REBOOT4 Ping 2207|Find "TTL=128">NUL IF NOT ERRORLEVEL 1 GOTO REBOOT5 Ping 2209|Find "TTL=128">NUL IF NOT ERRORLEVEL 1 GOTO REBOOT6 Ping 2210|Find "TTL=128">NUL IF NOT ERRORLEVEL 1 GOTO REBOOT7 Ping 2212|Find "TTL=128">NUL IF NOT ERRORLEVEL 1 GOTO REBOOT8 Ping 2215|Find "TTL=128">NUL IF NOT ERRORLEVEL 1 GOTO REBOOT9 Ping 2216|Find "TTL=128">NUL IF NOT ERRORLEVEL 1 GOTO REBOOT10 Ping 2218|Find "TTL=128">NUL IF NOT ERRORLEVEL 1 GOTO REBOOT11 :REBOOT1 shutdown \\2202 /R /T:05 /C :REBOOT2 shutdown \\2203 /R /T:05 /C :REBOOT3 shutdown \\2204 /R /T:05 /C :REBOOT4 shutdown \\2205 /R /T:05 /C :REBOOT5 shutdown \\2207 /R /T:05 /C :REBOOT6 shutdown \\2208 /R /T:05 /C :REBOOT7 shutdown \\2209 /R /T:05 /C :REBOOT8 shutdown \\2210 /R /T:05 /C :REBOOT9 shutdown \\2215 /R /T:05 /C :REBOOT10 shutdown \\2216 /R /T:05 /C :REBOOT11 shutdown \\2218 /R /T:05 /C Thats all well and good, but it may be totally not needed. My sheduled script to defrag is=defrag.vbs set WshShell = CreateObject("WScript.Shell") WshShell.Run "dfrg.msc" WScript.Sleep 1000 While WshShell.AppActivate("Disk Defragmenter") = FALSE WScript.Sleep 1000 Wend WshShell.AppActivate "Disk Defragmenter" WScript.Sleep 200 WshShell.SendKeys "%A" WScript.Sleep 200 WshShell.SendKeys "D" While WshShell.AppActivate("Defragmentation Complete") = FALSE WScript.Sleep 5000 Wend WshShell.AppActivate "Defragmentation Complete" WScript.Sleep 200 WshShell.Sendkeys "{TAB}" Wscript.Sleep 500 WshShell.Sendkeys "{ENTER}" Wscript.Sleep 500 WshShell.Sendkeys "%{F4}" I want it to run and then reboot the machine when done. Here is a script to reboot the machine=reboot.vbs strComputer = "ComputerNAme" Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate,(Shutdown)}!\\" & strComputer & "\root\cimv2") Set colOperatingSystems = objWMIService.ExecQuery _ ("Select * from Win32_OperatingSystem") For Each objOperatingSystem in colOperatingSystems ObjOperatingSystem.Reboot() Next If I can combine these into one script it would reboot after the defrag and I would have it only schedule one thing. How do I combine these scripts? Can it simply be added at the bottom? My goal is to defrag the pc's at midnight on the first of the month and then reboot when finished. Monthly defrag and reboot - anyweb - 2003-12-17 why reboot, defrag doesnt need a reboot cheers anyweb Monthly defrag and reboot - Oroshi - 2003-12-17 hate rebooting heh. coz it have to load up the background process.. not fast as linux. so Linux still the best :P Monthly defrag and reboot - Digerati - 2003-12-18 Yes the reboot is not totally nessecary (or however you spell it) I just wanted the machine to reboot after the defrag process. Sometimes I have seen the wscript stay in the task manger after defrag and I have also seen it run the cpu up real high and stick. I have no idea why but I wanted a reboot after defrag just in case. This is a monthly thing too. Lots of us never reboot so a monthly defrag and reboot seems not too much to ask. |