Neutro Posted October 7, 2015 Posted October 7, 2015 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! Identify active network connections and change DNS server - Easily export Windows network settings Clean temporary files from Windows users profiles directories - List Active Directory Groups members Export content of an Outlook mailbox to a PST file - File patch manager - IRC chat connect example Thanks again for your help Water!
funkey Posted October 7, 2015 Posted October 7, 2015 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 tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning.
Neutro Posted October 8, 2015 Author Posted October 8, 2015 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 Identify active network connections and change DNS server - Easily export Windows network settings Clean temporary files from Windows users profiles directories - List Active Directory Groups members Export content of an Outlook mailbox to a PST file - File patch manager - IRC chat connect example Thanks again for your help Water!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now