Advanced scripting / patching question: Is there a way to have an online shell script run on client time instead of server time?
The script will determine if a reboot is required and log the following message: "Verifying patching reboot status…”.
If the reboot is not required then the script will log the following message: “Reboot not required, exiting.” and the script will exit.
If the reboot is required then the script will log the following message: “Starting Alert Phase 1. Reboot in 90 minutes…” and will display the following notification window:
At the moment that this notification appears the script pauses for 60 min. The notification is also set to timeout in 59 min.
Following the 90 minute notification, the script will log the following message: “Starting Alert Phase 2. Reboot in 30 minutes…” and will display the following notification window:
At the moment that this notification appears the script pauses for 25 min. The notification is also set to timeout in 24 min.
Following the 30 minute notification, the script will log the following message: “Starting Final Alert Phase. Reboot in 5 minutes…” and will display the following two notification windows:
Here is the script:
REM Created by John Parkinson 06OCT2014
echo %DATE% %TIME% - Verifying patching reboot status...>>c:\Temp\KACE_Patching_Reboot.log
SET REBOOT=0
SET ALERTED=0
REM check to see if C:\Documents and Settings\All Users\Dell\KACE\user\KREBOOT_PENDING exists and if found moves to alerts
:REBOOT_CHECK
SET REBOOT=0
IF EXIST "C:\Documents and Settings\All Users\Dell\KACE\user\KREBOOT_PENDING" SET REBOOT=1
IF %REBOOT% equ 1 goto REBOOT_ALERTS
echo %DATE% %TIME% - Reboot not required, exiting.>>c:\Temp\KACE_Patching_reboot.log
GOTO :EOF
REM A series of prompts alerting the user at 90,60,30 and 5 minutes that the computer is going to reboot and they should save their work
:REBOOT_ALERTS
echo %DATE% %TIME% - Starting Alert Phase 1. Reboot in 90 minutes...>>c:\Temp\KACE_Patching_reboot.log
SET ALERTED=0
Start "" "C:\Program Files (x86)\Dell\KACE\KUserAlert.exe" -name="Akamai Helpdesk" -title="KACE Patching reboot" -message="KACE will automatically reboot your computer in 90 minutes, unless you have the opportunity to reboot sooner." -timeout="3540"
timeout /T 3600
echo %DATE% %TIME% - Starting Alert Phase 2. Reboot in 30 minutes...>>c:\Temp\KACE_Patching_reboot.log
Start "" "C:\Program Files (x86)\Dell\KACE\KUserAlert.exe" -name="Akamai Helpdesk" -title="KACE Patching reboot" -message="REMINDER: KACE will automatically reboot your computer in 30 minutes, unless you have the opportunity to reboot sooner." -timeout="1440"
timeout /T 1500
SET ALERTED=1
IF %ALERTED% equ 1 goto FINAL_ALERT
GOTO :EOF
REM A final alert and shutdown command issuing the reboot in 5 minutes
:FINAL_ALERT
echo %DATE% %TIME% - Starting Final Alert Phase. Reboot in 5 minutes...>>c:\Temp\KACE_Patching_reboot.log
Start "" "C:\Program Files (x86)\Dell\KACE\KUserAlert.exe" -name="Akamai Helpdesk" -title="KACE Patching reboot" -message="FINAL WARNING: KACE will automatically reboot your computer in 5 minutes, unless you have the opportunity to reboot sooner. Please save your work now." -timeout="300"
C:\Windows\System32\Shutdown.exe /r /t 300 /c "FINAL WARNING: KACE Patching reboot. Your computer will reboot in exactly 5 minutes, unless you have the opportunity to reboot sooner. Please save all of your work now."
EXIT
-
I left out one important detail. The end result that I am looking for is to have this run at 17:00 client time each day that it is enabled. - jparkins 10 years ago
Answers (3)
Comments:
-
nshah, thanks for the suggestion. I have actually tried the baked in methods of forcing reboots on machines and was met with poor results at best.
When I had tried to use the 5 prompts through the patch deployment schedule, it is so very limited on the message, not to mention that when an employee is busy and simply clicks 'snooze' they may not remember if they had just clicked snooze for the 2nd or the 4th time thus potentially causing a reboot that could result in lost work, productivity, etc...
Additionally the countdown method listed in the options is very poorly designed and from my experience does not work as it should.
Basically due to the number of different schedules I have for various departments (public sector, private, nocc, etc...) I needed something that would appeal to all and would give such verbose warnings and logging that no one should ever be able to call in the our help desk and say they did not know that their machine was going to be automatically rebooted. - jparkins 10 years ago