1
我在VBA上使用ShellExecute強制計算機進入休眠狀態(不休眠),因此我需要禁用休眠模式。我輸入了rundll32.exe,但在「powercfg.cpl -hibernate off」中出現錯誤。VBA - 如何使用ShellExecute強制計算機進入休眠狀態(而不是休眠)
我也試過:
powercfg.exe /hibernate off
和
powercfg -hibernate off
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (_
ByVal hwnd As Long, _
ByVal lpszOp As String, _
ByVal lpszFile As String, _
ByVal lpszParams As String, _
ByVal lpszDir As String, _
ByVal FsShowCmd As Long) As Long
Const SW_SHOWNORMAL As Long = 1
Sub DoSleep()
ShellExecute 0, "runas", "C:\WINDOWS\System32\rundll32.exe", "powercfg.cpl -h off", "C:\", SW_SHOWNORMAL
ShellExecute 0, "runas", "C:\WINDOWS\System32\rundll32.exe", "powrprof.dll,SetSuspendState 0,1,0", "C:\", SW_SHOWNORMAL
ShellExecute 0, "runas", "C:\WINDOWS\System32\rundll32.exe", "powercfg.cpl -hibernate on", "C:\", SW_SHOWNORMAL
End Sub