I generally run powershell.exe and keep a window open. I can type in the command to run a script to shutdown the system at a specific time. This script calls the following function.
Function Do_Suspend {
Start-Sleep -Seconds 15
# $msg = "Entering Standby at: " + (Get-date).DateTime
# Write-EventLog -LogName system -Source EventLog -EventID 1 -message $msg
write-host "Entering Standby at: " (Get-date).DateTime
c:\windows\system32\rundll32.exe powrprof.dll SetSuspendState 0,1,0
Start-Sleep -Seconds 10
# $msg = "Waking up from standby at: " + (Get-date).DateTime
# Write-EventLog -LogName system -Source EventLog -EventID 1 -message $msg
write-host "Waking up from standby at: " (Get-date).DateTime
Start-Sleep -Seconds 10
}
The system then suspends. When the system wakes up again it continues and returns to the point Do_Suspend was called and continues to process commands. It is necessary for me to type in the command to do the shutdown. When I upgraded to windows 10 I created a scheduled task to call the script to do the suspend. But when the computer wakes up the script did not continue. But when I did a ctrl-C the script continued.
I have two questions. 1. Why didn't the script continue after the wake up. 2. Is there a way to interrupt the current powershell windows to run a script.
Thanks
RAC