我希望能够让我的笔记本电脑从命令行进入睡眠状态。 据微软说,Win32_Battery WMI类有一个SetPowerState方法 ,看起来应该能够做到这一点,但是,在我试过的几个笔记本电脑上,我只是得到不同的错误,指出这个方法没有实现或其他各种失败:
-> 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
是否有任何笔记本电脑执行此? 知道另一种方法来做到这一点? 没有必要是WMI,任何使机器处于与大多数笔记本电脑相同的低功耗状态。
您可以在PowerShell提示符下使用以下命令:
Add-Type -Assembly System.Windows.Forms [System.Windows.Forms.Application]::SetSuspendState("Suspend", $false, $true)
从cmd.exe运行该命令应该hibernate您的计算机:
Rundll32.exe Powrprof.dll,SetSuspendState