Tadeu Bento

Windows: Quickly Disable Lock Screen Password

Today I will show you how to shortcut on Windows that will quickly disables/enables the password prompt on lock screen – the one that shows when, after few minutes of inactivity, we wake up the screen. Such shortcut especially useful if you use a machine that is sometimes exposed to the public.

1. Create a PowerShell script SleepLock.ps1:

$action = $args[0]
if ($action.Length -eq 0) {
    Write-Output "Sleep Screen Lock Tool"
    Write-Output "Please specify if the screen should be locked on sleep."
    Write-Output "   SleepLock.ps1 1"
    Write-Output "   SleepLock.ps1 0"
    Exit
}

$signature = @"
[DllImport("user32.dll")]
public static extern bool SystemParametersInfo(int uAction, int uParam, ref int lpvParam, int flags );
"@

$systemParamInfo = Add-Type -memberDefinition  $signature -Name ScreenSaver -passThru

Function Set-OnResumeDisplayLogon {
    Param ([Int32]$value)
    [Int32]$nullVar = 0
    $systemParamInfo::SystemParametersInfo(119, $value, [REF]$nullVar, 2)
}

Set-OnResumeDisplayLogon([int]$action)

2. Create two shortcuts with the following targets:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -f "C:\Users\XXX\Scripts\SleepLock.ps1" 1

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -f "C:\Users\XXX\Scripts\SleepLock.ps1" 0

Note the -f and quotes around the script path, those are required to make it work. The target ends with either 0 or 1 in order to respectively disable to disable or enable the lock screen password.

Exit mobile version