Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $timeout = 3600
  2.  
  3. $delay = 3600
  4.  
  5. $delayed = $true
  6.  
  7. function inHours($time) {
  8.     [Math]::Round($time / 3600, 2)
  9.     return
  10. }
  11.  
  12. do {
  13.     shutdown /s /f /t $timeout /c "Запланированное выключение компьютера"  
  14.  
  15.     $msgBoxInput = [System.Windows.MessageBox]::Show("Этот компьютер автоматически выключится через $(inHours -time $timeout)ч. Отложить выключение компьютера?",'Бери шинель, пошли домой','YesNo')
  16.  
  17.     switch  ($msgBoxInput) {
  18.  
  19.         'Yes' {
  20.  
  21.         shutdown /a
  22.  
  23.         $msgBoxInput = [System.Windows.MessageBox]::Show("Выключение отложено на $(inHours -time $delay)ч.")
  24.  
  25.         Start-Sleep -Seconds $delay
  26.  
  27.         }
  28.  
  29.         'No' {
  30.  
  31.         $delayed = $false
  32.  
  33.         }
  34.     }
  35. } while ($delayed)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement