How to disable sleep mode via CMD?

The command you are looking for is powercfg. Open a command prompt and type powercfg –q >poweroptions.txt

This will create a text file (poweroptions.txt) with all the GUIDs for the power settings. Open the poweroptions.txt file and find the GUID for the current power scheme. This should be at the very top of the file and will look like this:

Power Scheme GUID: 381b4222-f694-41f0-9685-ff5bb260df2e (Balanced)

Copy and paste just the GUID (in this example - 381b4222-f694-41f0-9685-ff5bb260df2e) into a new empty text file. Then scroll through and find the Subgroup GUID for the “Power buttons and lid” actions. Copy and paste this GUID into that same new text file as a separate line. Now find the Power Setting GUID for “Lid close action” and copy and paste that one under the other two. Please also note the ‘Possible Setting Index’ numbers for the option that you will want to set it to (disabled is 000). You will have to run the command once for each power scheme, DC and AC power in order to cover both situations. The command will look like this:

Powercfg –SETACVALUEINDEX [put power scheme GUID here] [put subgroup GUID here] [put power setting GUID here] 000

I tested this and my command looks like this:

powercfg -SETACVALUEINDEX 381b4222-f694-41f0-9685-ff5bb260df2e 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 000

The second command is for when the user is on battery and is exactly the same except we use the switch –SETDCVALUEINDEX.

Here is the official Powercfg command-line options page from Microsoft for further reference.


The topic here is How to disable sleep mode via CMD?

Assuming you have configured the lid of your laptop to do nothing when closed:

powercfg -x -standby-timeout-ac 0

(somehow the switch -x doesn't work for me so I've changed it to /x and it works. the rest of the switches stay -standby-timeout-ac)

As shown on Microsoft's Technet page "Powercfg Command-Line Options" (https://technet.microsoft.com/en-us/library/cc748940(v=ws.10).aspx), the command is:

> powercfg -x setting value (the value you're looking at is "standby")

therefore: > powercfg -x -standby-timeout-ac minutes (disable = 0 minutes)

NOTE: ac = connected to electric power / dc = works on battery (so if you want to disable sleep mode while working on battery power, replace the "ac" with "dc" in the command, so it will look like powercfg -x -standby-timeout-dc 0)


Based off of the previous answer I wrote a batch file.

@echo off

for /f "tokens=4 delims= " %%i IN ('powercfg -q ^| find "Power Scheme GUID:"') do Set StrOne=%%i
for /f "tokens=3 delims= " %%i IN ('powercfg -q ^| find "(Power buttons and lid)"') do Set StrTwo=%%i 
for /f "tokens=4 delims= " %%i IN ('powercfg -q ^| find "(Lid close action)"') do Set StrThree=%%i 

powercfg -SETACVALUEINDEX %StrOne% %StrTwo% %StrThree% 000

You need to change %%i to %i if trying to run these commands directly in a command prompt (outside of a batch).