/build/static/layout/Breadcrumb_cap_w.png
08/07/2019 280 views

Hello,


I'm hoping to find a method of prompting a user to restart their system after a script has run, giving them the option to restart now or snooze, similar to a pending reboot when KACE is patching.


Here is an example workflow.

- Script performs an action that requires a reboot once finished.

- Dialog box is created prompting the user to restart and gives them the option to restart now or snooze. The reboot would automatically occur if there is no interaction within a set timeout such as 15 minutes.


Are there any native KACE functions or executables which can provide this functionality?


Thank you!


1 Comment   [ + ] Show comment

Comments

  • I believe this is not possible with a Script...
    • I could pull something of this nature off using PSAppDeployment Toolkit but don't want to re-invent the wheel if there are already KACE utilities that I could leverage for this task.
  • This content is currently hidden from public view.
    Reason: Removed by member request For more information, visit our FAQ's.

All Answers

1

this is not possible natively.
If you use an OnlineKScript you can notify before run, update and destroy a message window.
After that window you could trigger a reboot with the shutdown.exe

Answered 08/08/2019 by: Nico_K
Red Belt

1

You can use something like AutoIT to create a message window and prompt user by adding it as the last task.  Down and Dirty run a message as a batch file last and check the box to show it in the script (visible)

@echo off
echo IT dept has just finished updating blah blah software.
echo You need to restart for changes to take effect.
set /p in=Enter 1 to restart now or press enter to keep working:
echo %in%
if /I "%in%" EQU "1" shutdown /r /t 2 /f
Answered 08/08/2019 by: SMal.tmcc
Red Belt

0

vbscript version of this would be something like this.  It won't time out after 15 mins, but the message will be modal meaning it will remain on top of other windows till a choice is made.  I commented out the restart so you can test how it works without worrying about it rebooting.  just remove the quote before restart in the middle of the loop to use the restart function.  for the popups, you can change the timeout for them by changing the "30" to however many seconds you want to use ( say 3 while testing for example), the delay before the user is prompted again is in the sleep line, this is in milliseconds - 1 second = 1000 milliseconds, so 15 mins = 15 X 60 seconds x 1000 = 900000

this page explains msgbox if you want to play with the message box options - https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/scripting-articles/sfw6660x(v=vs.84) 


answer = 0

 Do While answer <> 6
  Dim answer
  answer=MsgBox("Your PC needs to Restart" & vbCrLf & "Are you ready to restart now?",4148,"Install Complete, Reboot Required")
  If answer = 6 Then              ' Yes clicked, call restart Function.
   wshShell.Popup "Ok chosen, restarting", 30, "Restarting" ' this popup will remain for 30 seconds before the restart begins.
    ' Restart
  ElseIf answer = 7 Then ' No clicked, sleep for 15 minutes
   wshShell.Popup "Delayed for 15 minutes", 30, "Restart Delayed" ' this popup will remain for 30 seconds before disappearing.
   WScript.Sleep 900000       '15 mins = 900000
  End If
 Loop


Function Restart
 Dim colOperatingSystems
 Dim objWMIService
 Dim objOperatingSystem
 Dim strComputer
 strComputer = "."
 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
End Function

Answered 08/14/2019 by: Peakay
White Belt