Suspend or hibernate from PowerShell

前端 未结 4 2072
一生所求
一生所求 2021-02-01 20:49

I am interested in using Windows PowerShell to suspend or hibernate a computer. How do you achieve this?

I am already aware of the Stop-Computer and R

4条回答
  •  情书的邮戳
    2021-02-01 21:09

    I tried reducing this down to a one-liner but was getting an error. Here's my solution:

    [Void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") 
    [System.Windows.Forms.Application]::SetSuspendState("Hibernate", $false, $false);
    

提交回复
热议问题