script stays in taskman
Posted: Fri Feb 22, 2019 7:46 am
I have a form that is compiled into an .EXE. It displays a message saying your system will reboot in 5 min, please close your apps. I've run this on a few different machines and on 2 of them after the reboot this compiled .exe was STILL showing as a Process in TaskMan and the machine kept rebooting ever 5 min. Why? what in this code would cause that behavior?
Code: Select all
# This will create a countdown timer on the form
$FormEvent_Load={
$labelTime.Text = "{0:D2}" -f $TotalTime
}
# Set countdown to 3 minutes or 180 seconds
$TotalTime = 300
$script:StartTime = (Get-Date).AddSeconds($TotalTime)
$timerUpdate.Start()
$timerUpdate_Tick={
#Use Get-Date for Time Accuracy
[TimeSpan]$span = $script:StartTime - (Get-Date)
#Update the display
$formRebootSystem.Text = $labelTime.Text = "{0:N0}" -f $span.TotalSeconds
if($span.TotalSeconds -le 0)
{
# Once 300 seconds have gone by reboot the system
Restart-Computer localhost -Force
}
}
$labelTime_Click={
#TODO: Place custom script here
}
$FormEvent_Load={
#TODO: Place custom script here
}
$labelSecondsRemainingUnti_Click={
#TODO: Place custom script here
}