Skip to main content

Power Management - No Sleep on AC Power

Summary

This script sets the computer to not sleep when plugged in.

Time Saved by Automation: 5 Minutes

Sample Run

Sample Run

Dependencies

Download NeverSleepAC.exe

Variables

Variable NameDescription
ProjectNameThis represents the name of the executable, which in this case will be NeverSleepAC.
BaseURLThis represents the base URL, which will be https://file.provaltech.com/repo in this case.
WorkingDirectoryC:/ProgramData/provaltech/app/@ProjectName@
EXEURL@BaseURL@/app/@ProjectName@.exe
EXEPath@WorkingDirectory@/@ProjectName@.exe
EXETempPath@WorkingDirectory@/@ProjectName@-temp.exe
EXELog@WorkingDirectory@/@ProjectName@-log.txt
EXEErrorLog@WorkingDirectory@/@ProjectName@-errors.txt
LogContent@EXELog@

Process

This script will download the NeverSleepAC.exe from NeverSleepAC.exe. The script is a .NET wrapper that retrieves the three GUIDs required for powercfg: active scheme, subgroup, and setting. It gets the currently loaded power plan, which allows it to adjust user settings from the system account. The script modifies the values for only the AC settings (plugged in) of that current plan:

  • Sleep after = Never
  • Allow hybrid sleep = Off
  • Hibernate after = Never
  • Lid Close Action = Nothing (which is only present on mobile hardware).

The script will download the EXE file and execute it.

Output

  • Script log