/build/static/layout/Breadcrumb_cap_w.png

Advanced scripting / patching question: Is there a way to have an online shell script run on client time instead of server time?

I have written a script that will be enabled for a specified duration each month as part of our fairly complex patching process. 

The script is a final measure that forces a reboot of users machines that have not done so themselves come this phase of the patch cycle. 

The issue I am facing is that we have clients in several different countries around the globe and therefore need the script to execute client time and not sever. I have looked into using a KScript for this but from what I could tell I am limited and I will not be able to produce the EXACT same behavior through the KScript. 

Does anyone know if what I am trying to do is possible?




Here is what the script does:

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   


1 Comment   [ + ] Show comment
  • 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)

Posted by: nshah 10 years ago
Red Belt
1
Very nicely done. 

Not a scripting guy but I am curious why you wouldn't use the patching engine options? The patching scheduling gives you the options to schedule via server or agent time zone. it also gives you the option to set up a set number of prompts before a reboot is forced. Ex. selecting 5 in the Number of Prompts field would give the user 4 chances to reboot their box and on the 5th is forced.

Yours have different messaging would give them better notification but might be worth a look, if you haven't already. 

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
Posted by: EdT 10 years ago
Red Belt
0
Would it not be possible to add code to the script that checks the local machine time and then responds accordingly?
Posted by: fatfingers 9 years ago
White Belt
0
Did you ever figure this out?  How about scheduling the same script to run at different times for different clients / time zones?

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ