Created
November 27, 2012 02:14
-
-
Save scichelli/4151973 to your computer and use it in GitHub Desktop.
Show an alert and then set the computer to sleep
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$WarningDuration = 5 | |
$MessagePlural = "" | |
if ($WarningDuration -gt 1) { $MessagePlural = "s" } | |
[System.Media.SystemSounds]::Asterisk.play() | |
[void] [Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | |
[windows.forms.messagebox]::show(("Save your work. Sleep in {0} minute{1}." -f $WarningDuration, $MessagePlural)) | |
Start-Sleep -Second ($WarningDuration * 60) | |
[System.Media.SystemSounds]::Beep.play() | |
Start-Sleep -Second 2 | |
[System.Windows.Forms.Application]::SetSuspendState("Suspend", $false, $true) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment