Hello,
I have created a script that shuts down the computer. It is first checked whether the Explorer.exe process runs when yes, a message appears that the PC is shut down. Unfortunately, the script now waiting for input.
What do I need to adjust so that from then runs a timer? Can you help me?
Here ist the script:
# Parameter
$Counter = "1"
$TimeLeft = "5"
$wshell = New-Object -ComObject Wscript.Shell
$process = Get-WmiObject -Query "Select * from Win32_Process Where Name = 'explorer.exe'"
if ($prcess.Count -eq 0)
{
Stop-Computer
}
while ($Counter -lt 11)
{
$Return = $wshell.Popup("Your computer will shutdown in " + $TimeLeft + " minutes. Click OK to cancel the shutdown.",0,"Shutdown Pending",32)
If ($Return -eq 1)
{
$wshell.Popup("Shutdown has been cancelled!", 6,"SHUTDOWN CANCELLED", 0)
exit
}
$TimeLeft = $TimeLeft - .5
$Counter = $Counter + 1
}
Stop-Computer