Skip to content

Instantly share code, notes, and snippets.

@flq
Created February 9, 2012 09:35
Show Gist options
  • Save flq/1778824 to your computer and use it in GitHub Desktop.
Save flq/1778824 to your computer and use it in GitHub Desktop.
Powershell function to bring your PC to sleep
function zzz {
$source = @"
[DllImport("powrprof.dll")]
public static extern void SetSuspendState(bool hibernate, bool forceCritical, bool disableWakeEvent);
"@
$app = Add-Type -Namespace "Standby" -MemberDefinition $source -Name Sleep -PassThru;
$app::SetSuspendState($false,$true,$false);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment