Jump to content

Where to find power settings in registry?


Recommended Posts


  • 1 month later...
  • 1 year later...

I thought i would ressurect this old post - i have been having trouble finding a way to set the energy buttons (such as when I close the lid etc) state via command line but unfortunately cannot find any way of doing it as it is one of the few power options not covered in powercfg.

Anybody have any ideas yet?

Link to comment
Share on other sites

  • 5 years later...

ok now the question I have is. How do I change it so that when I close the lid on my computer the computer does not shut down. I dont see how to do this...

Found this thread while searching for the same thing as you and 'Snife'. If I find a solution I will post it - even though this thread is over 6 years old haha. Maybe NLite has something built in..

Link to comment
Share on other sites

This is something I bodged a while ago - there are probably better ways, and it's been minimally tested on xp 32bit only...

' _power.vbs
Option Explicit

Const HKCU=&H80000001

Dim WshShell, fso, oReg, strLog, oLog
Dim temp, userprofile
Dim sHive, sKey, sValue, oArray, oArrayNew

set WshShell = CreateObject("WScript.Shell")
Set fso = CreateObject ("Scripting.FileSystemObject")
Set oReg=GetObject( "winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")

temp = WshShell.ExpandEnvironmentStrings("%temp%")
userprofile = WshShell.ExpandEnvironmentStrings("%userprofile%")

strLog = temp & "\_power.txt"

if not fso.fileexists(strLog) then fso.CreateTextFile(strLog) end if
Set oLog = fso.OpenTextFile(strLog,8) '8 = ForAppending

If Wscript.Arguments.Count = 1 Then
oLog.WriteLine Now & " " & Wscript.Arguments(0)
End If

sHive = HKCU
sKey = "Control Panel\PowerCfg\GlobalPowerPolicy"
sValue = "Policies"

'do nothing when lid is closed
alter "52", "off", CInt("&H02")
alter "63", "on", CInt("&H80")
alter "64", "off", CInt("&H02")
alter "75", "on", CInt("&H80")

'dont ask for password when resume from standby
alter "172", "off", CInt("&H04")


WScript.Quit(0)

'byte array is zero based

Sub alter (iByte, action, iVal)
oReg.GetBinaryValue sHive, sKey, sValue, oArray
oArrayNew = oArray
select case action
case "on"
oArrayNew(iByte) = oArray(iByte) OR iVal
oReg.SetBinaryValue HKCU, sKey, sValue, oArrayNew
oLog.WriteLine Now & " " & iByte & " " & Hex(oArray(iByte)) & " -> " & Hex(oArrayNew(iByte))
case "off"
if ((oArray(iByte) AND iVal) = iVal) then
oArrayNew(iByte) = oArray(iByte) XOR iVal
end if
oReg.SetBinaryValue HKCU, sKey, sValue, oArrayNew
oLog.WriteLine Now & " " & iByte & " " & Hex(oArray(iByte)) & " -> " & Hex(oArrayNew(iByte))
end select
end sub

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...