I have a requirement that enable autosleep in batch file. The reason is i want to autosleep my computer after getting off work, but disable autosleep when i'm on duty

  • I know how to auto wake up my computer by using RTC in BIOS
  • I know how to run a batch at certain time by using scheduler

The only thing I don't know is how to enable or disable autosleep by batch.


What I want is to set autosleep time

Use powercfg.


Set timeout to 5 minutes:

powercfg -x standby-timeout-ac 5

Set timeout to never:

powercfg -x standby-timeout-ac 0


powercfg [Options]


-change setting value
-x setting value

Modify one of the following settings in the current power scheme:
          -monitor-timeout-ac minutes
          -monitor-timeout-dc minutes
          -disk-timeout-ac minutes
          -disk-timeout-dc minutes
          -standby-timeout-ac minutes
          -standby-timeout-dc minutes
          -hibernate-timeout-ac minutes
          -hibernate-timeout-dc minutes

Setting any value to 0 will set the timeout=Never

AC settings are used when the system is on AC power. 
DC settings on battery power.

Source powercfg

Further Reading

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.