REM Synchronize the workstation time with the server echo _ Synchronizing Time ... net time %LOGONSERVER% /set /yes >nul REM Determine Operating System type echo _ Determining Operating System ... ver | find "4.0" >nul if not errorlevel 1 set WIN_VERSION=NT ver | find "5.0" >nul if not errorlevel 1 set WIN_VERSION=2K ver | find "5.1" >nul if not errorlevel 1 set WIN_VERSION=XP ver | find "5.2" >nul if not errorlevel 1 set WIN_VERSION=2K3 if "%WIN_VERSION%"=="98" set WIN_VERSION=95 if exist %windir%\command.com set WIN_VERSION=95 if "%WIN_VERSION%"=="95" echo – Windows 95/98 Detected if "%WIN_VERSION%"=="NT" echo – Windows NT 4.0 Detected if "%WIN_VERSION%"=="2K" echo – Windows 2000 Detected if "%WIN_VERSION%"=="XP" echo – Windows XP Detected if "%WIN_VERSION%"=="2K3" echo – Windows 2003 Detected REM Workstation Scheduled Reboots REM Do you apply patches, and need to ensure the workstation is rebooting every once in awhile for the patches to take affect? This will determine the last reboot time, and if not within the past 7 days, schedule a reboot for Saturday at 2am. This requires the Windows remote registry service remain enabled and accessible (some workstation firewalls may block it). echo _ Determining Last Reboot Time ... if not exist %windir%\system32\uptime.exe xcopy /D /Y %LOGONSERVER%\NETLOGON\uptime.exe %windir%\system32 if not exist %windir%\system32\shutdown.exe xcopy /D /Y %LOGONSERVER%\NETLOGON\shutdown.exe %windir%\system32 if not exist %windir%\system32\bmail.exe xcopy /D /Y %LOGONSERVER%\NETLOGON\bmail.exe %windir%\system32 FOR /F "tokens=6,6 delims= " %%A IN ('%windir%\system32\uptime.exe ^| FIND "\\"') DO ( IF %%A=="to" echo – Unable to pull uptime of local machine. IF NOT %%A LSS 7 ( echo – Scheduling Reboot of Local Host for Saturday at 2:00am. %windir%\system32\at.exe | %windir%\system32\find "NET.EXE" >nul if errorlevel 1 %windir%\system32\AT 12:00a /NEXT:Saturday C:\WINNT\SYSTEM32\NET.EXE send %COMPUTERNAME% "Your computer will be rebooting Saturday morning 2:00am." >nul %windir%\system32\at.exe | %windir%\system32\find "SHUTDOWN.EXE" >nul if errorlevel 1 %windir%\system32\AT 2:00a /NEXT:Saturday C:\WINNT\SYSTEM32\SHUTDOWN.EXE /L /R /T:300 "Please save open work, reboot of your computer in 5mins." /C /Y >nul %windir%\system32\bmail.exe -s 172.16.1.11 -t %username%@company.com,sysadmin@company.com -f sysadmin@company.com -a "%COMPUTERNAME% Will Reboot Saturday 2am" -b "The system has detected that the computer %computername% your user account logged into has not been rebooted in the last 7 days. %computername% has automatically been scheduled to be rebooted this coming Saturday at 2am (local time to the computer). This is to allow for the latest system patches to be successfully applied. Please ensure that all open files are saved and closed at that time. Alternatively you can reboot your computer before then and login to avoid the scheduled reboot. Contact your local IT guru if you have any questions or concerns." ) IF %%A LSS 7 ( FOR /F "tokens=1,6 delims= " %%a IN ('%windir%\system32\at.exe ^| %windir%\system32\find "NET.EXE"') DO %windir%\system32\at.exe %%a /d FOR /F "tokens=1,6 delims= " %%a IN ('%windir%\system32\at.exe ^| %windir%\system32\find "SHUTDOWN.EXE"') DO %windir%\system32\at.exe %%a /d ) echo – %COMPUTERNAME% last rebooted %%A days ago.