Jump to content

Recommended Posts

Posted

Hey guys,

Here is the code to setup any laptop to not do anything if the lid is closed. Note: this will only work if you use Windows default power plans. If not, then google the command below and adapt it with your power plan GUID :)

RunWait(@ComSpec & " /c " & 'c:\windows\system32\powercfg.exe -SETDCVALUEINDEX 381b4222-f694-41f0-9685-ff5bb260df2e 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 0', "", @SW_HIDE)
sleep(50)
RunWait(@ComSpec & " /c " & 'c:\windows\system32\powercfg.exe -SETDCVALUEINDEX 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 0', "", @SW_HIDE)
sleep(50)
RunWait(@ComSpec & " /c " & 'c:\windows\system32\powercfg.exe -SETDCVALUEINDEX a1841308-3541-4fab-bc81-f71556f20b4a 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 0', "", @SW_HIDE)
sleep(50)
RunWait(@ComSpec & " /c " & 'c:\windows\system32\powercfg.exe -SETACVALUEINDEX 381b4222-f694-41f0-9685-ff5bb260df2e 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 0', "", @SW_HIDE)
sleep(50)
RunWait(@ComSpec & " /c " & 'c:\windows\system32\powercfg.exe -SETACVALUEINDEX 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 0', "", @SW_HIDE)
sleep(50)
RunWait(@ComSpec & " /c " & 'c:\windows\system32\powercfg.exe -SETACVALUEINDEX a1841308-3541-4fab-bc81-f71556f20b4a 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 0', "", @SW_HIDE)
sleep(50)

Enjoy!

Posted

Hello, would be nice if you use some constants like $DefaultPowerPlanGuid and so on. And then I would pack it into a function to disable and enable functions when laptop lid is closed. Why do you need the Sleep function, when using RunWait?

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Posted

I'm sorry I don't have  a lot of time to make it nicer, I just copy pasted it from a script i'm doing for work since I didn't find a precise answer on the forum about this.

I use sleep after runwait just in case, but yeah maybe it's not needed!

Sometimes I like to find code to copy paste and use it, so I shared it in that spirit :)

But if you want to make it better, go ahead :)

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...