2

For various reasons, we want our clients' computers to not sleep when on AC. We have been running the following script with moderate success:

powercfg /change standby-timeout-ac 0

However, the script fails on a lot of computers (including computers that aren't on a domain) with the following error message:

Group policy override settings exist for this power scheme or power setting.

I realize that this could easily be solved with a GPO, but that's not a feasible solution, since a lot of our clients are small businesses without a domain. Is there a way to make powercfg override the local GPO?

HopelessN00b
  • 53,795
  • 33
  • 135
  • 209
MikeTG
  • 23
  • 1
  • 3

1 Answers1

0

It's either "no," with a "but," or "yes," with a "however."

We'll take the "no" approach first - no, group policies overrule configurations made by applications, not the other way around, and this is by design. If you really want, with some creative application of security ACLs to the relevant registry keys, you can prohibit SYSTEM from being able to apply group policy, effectively allowing you to override them with an application... but, this is a really bad idea.

To put it another way, yes, since group policies are just registry entries, you can alter them to your heart's content with your registry editor of choice, and put yourself in a really awkward state where you effectively override group policy by preventing SYSTEM from accessing the registry keys that are the group policy in question. However, there's a much better approach to the problem, which is to configure the group policy in question. (Yes, local group policies are every bit as editable as domain group policies.)

In this case, you can edit the setting with the Local Group Policy Editor (MMC snapin), but it looks like you're after a scripted option, which is also possible. Call reg.exe from your script, or a command line, and have it write the appropriate value to the correct key. In this case, you want the key at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power, named HibernateEnabled, with a REG_DWORD value type of 0.

Should look something like the below:

REG ADD HKLM\SYSTEM\CurrentControlSet\Control\Power /v HibernateEnabled /t REG_DWORD /d 0

This will disable hibernation, and if done after a conflicting group policy runs, will overwrite whatever value the group policy sets. This, of course, is probably not ideal, since you'd have to run that every time the computer boots, and you only want to disable hibernation when on AC power, so you'd probably want to programmatically edit the group policy within the registry. The easiest way to find the appropriate reg key would be to change that setting with the Local Group Policy Editor, while ProcMon is running, and use it to show you the group policy setting you just modified.

(Using the GUI, it's found under Computer Configuration\Administrative Templates\System\Power Management\Sleep Settings.)

Once you've used ProcMon found the key you're after, and know what value to set it to, you can plug it into reg.exe, as in the example I gave above to configure the local group policy as you specify. Being a command line command, you'll get something you can use manually, or paste into a script, as the situation dictates.

HopelessN00b
  • 53,795
  • 33
  • 135
  • 209