This one makes sure general settings are likely helpful, and also deals with two common troublemakers:
# General powercfg /change monitor-timeout-ac 0 powercfg /change monitor-timeout-dc 15 powercfg /change standby-timeout-ac 0 powercfg /change standby-timeout-dc 120 powercfg /change hibernate-timeout-ac 0 powercfg /change hibernate-timeout-dc 180 powercfg /change disk-timeout-ac 0 powercfg /change disk-timeout-dc 60 # Unhides and zeroes hidden "System unattended sleep timeout" which can cause problems # including, sometimes, automatic unwanted logoff powercfg -attributes sub_sleep 7bc4a2f9-d8fc-4469-b07b-33eb785aaca0 -ATTRIB_HIDE powercfg -setacvalueindex scheme_current sub_sleep 7bc4a2f9-d8fc-4469-b07b-33eb785aaca0 0 # Disable hybrid sleep both AC powered and DC powercfg -setacvalueindex scheme_current sub_sleep 94ac6d29-73ce-41a6-809f-6363ba21b47e 0 powercfg -setdcvalueindex scheme_current sub_sleep 94ac6d29-73ce-41a6-809f-6363ba21b47e 0 # Reapply current power scheme powercfg -setactive scheme_current