Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'd like to be able to put my laptop to sleep from the command line. According to Microsoft, the Win32_Battery WMI class has a SetPowerState method that looks like it should be able to do this, however, on several laptops I've tried, I just get different errors indicating this method is not implemented or other various failures:

-> gwmi Win32_Class
Get-WmiObject : Retrieving the COM class factory for component with CLSID {EB87E1BD-3233-11D2-AEC9-00C04FB68820} failed
 due to the following error: 80040154.
At line:1 char:5
+ gwmi <<<<  Win32_Class
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMException
    + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands.GetWmiObjectCommand

Do any laptops implement this? Know another way to do this? Doesn't have to be WMI, anything that puts the machine in the same low power state as shutting the lid does on most laptops.

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

This command run from cmd.exe should hibernate your computer:

Rundll32.exe Powrprof.dll,SetSuspendState
share|improve this answer
add comment

You may use the following commands in a PowerShell prompt:

Add-Type -Assembly System.Windows.Forms
[System.Windows.Forms.Application]::SetSuspendState("Suspend", $false, $true)
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.