.EXE number 1 is called ParentBoot.exe
.EXE number 2 is called RebootUtility.exe
ParentBoot.exe will check for system up time. If your system has not been rebooted for 'x' number of days it then launches RebootUtility.exe. RebootUtility.exe prompts the user with a dialog. This dialog has 2 buttons. "Reboot Now" & "Delay Reboot for 1 Hour". (note: if they never press either one the system will reboot in 5 minutes).
If the user pressed "Delay Reboot for 1 Hour" I execute this code
$regkeypath = "hklm:\Software\MGH"
$value1 = (Get-ItemProperty $regkeypath).OneHour
If ($value1 -contains '1') { Start-Sleep -m 1 }
ELSE { New-ItemProperty HKLM:\SOFTWARE\MGH -name "OneHour" -Value "1" }
My issue/question stems from ParentBoot.exe. After it launches RebootUtility.exe it sleeps for 15 seconds to see if they pressed "Delay Reboot for 1 Hour" But what if they wait 60 seconds? Or 90 seconds?
So can PowerShell check for a reg key and if not there Loop until it does find it? And if it loops for 5 min then the system will reboot anyway. Or the user pressed Reboot Now and then it's all good.
While(key does not exist)
Delay(2)
EndWhile
Something like that but in PowerShell