Tuesday, April 16, 2013

Windows 8 Lock Screen Timout

Simple script to set the Lock Screen Timout in Windows 8 to be the same as the screen sleep.  This is useful for Windows 8 PCs that are connected to AC power so that lock screen notifications can still be seen until the screen enters sleep mode.

The default setting of 60 seconds is useful for mobile devices to preserve battery, but for office use, this defeats the purpose of having an interactive lock screen.


@echo off
cls
REM ############################################################################
REM #                      CONSOLE LOCK FIX WINDOWS 8 PC                       #
REM ############################################################################
REM # Description: Sets console lock to occur when screen sleeps (i.e. 10 mins)#
REM # Author:  A. Tres Finocchiaro, 2013-04-16                                 #
REM ############################################################################
REM #############  AVAILABLE POWER PLANS ##############
set BALANCED=381b4222-f694-41f0-9685-ff5bb260df2e
set PERFORMANCE=8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
set POWERSAVE=a1841308-3541-4fab-bc81-f71556f20b4a
REM #################### GROUPS #######################
set DISPLAY=7516b95f-f776-4464-8c53-06167f40cc99
REM ################# SETTING GUID ####################
set CONLOCK=8ec4b3a5-6868-48c2-be75-4f3044be88a7
set DISPLAYIDLE=3c0bc021-c8a8-4e07-a973-6b14cbcb2b7e
REM ######## PATH TO PWRCONFIG EXECUTABLE #############
set PWRCFG=%windir%\System32\powercfg.exe
echo Lock Screen Timeout Changed (Windows 8 Only):
FOR /F "tokens=*" %%a in ('%PWRCFG% /q %BALANCED% %DISPLAY% %DISPLAYIDLE% ^| FIND "AC"') DO set TIME=%%a
set /a TIME=%TIME:~-11%
%PWRCFG% /setacvalueindex %BALANCED% %DISPLAY% %CONLOCK% %TIME%
set /a TIME=%TIME%/60
echo Balanced profile set to: %TIME% minutes
FOR /F "tokens=*" %%a in ('%PWRCFG% /q %PERFORMANCE% %DISPLAY% %DISPLAYIDLE% ^| FIND "AC"') DO set TIME=%%a
set /a TIME=%TIME:~-11%
%PWRCFG% /setacvalueindex %PERFORMANCE% %DISPLAY% %CONLOCK% %TIME%
set /a TIME=%TIME%/60
echo Performance profile set to: %TIME% minutes
FOR /F "tokens=*" %%a in ('%PWRCFG% /q %POWERSAVE% %DISPLAY% %DISPLAYIDLE% ^| FIND "AC"') DO set TIME=%%a
set /a TIME=%TIME:~-11%
%PWRCFG% /setacvalueindex %POWERSAVE% %DISPLAY% %CONLOCK% %TIME%
set /a TIME=%TIME%/60
echo Powersave profile set to: %TIME% minutes
echo.
echo You may need to reboot for these timeouts to take effect.
echo If errors are encountered, you may need to run this script as administrator.

No comments: