Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a power management setting (set up through the Control Panel) that turns the monitor off after 5 minutes of idling but keeps the power on all time, if the laptop is connected to power. Under this setting, however, the computer doesn't lock itself and becomes vulnerable to any passerby's attempt to log in if I'm not around.

Is there any way to force lock in this situation? (I can force lock if I have the laptop go sleep, but for immediate access I'd like to keep the power on when the laptop is connected to power.)

share|improve this question

3 Answers 3

up vote 4 down vote accepted

Lock Windows using Windows logo keyL when you walk away from the computer...Done!

share|improve this answer
That's even better. I don't have to put the computer to sleep (which wreaks havoc with internet connection, which is a well-known issue) or wait for the screen saver to kick in. Thanks! – Anon Jul 4 '13 at 22:37

You can use the screensaver that can only be turned off with a password:

  • On the Start menu, click Control Panel.
  • Click Display, and then click Screen Saver.
  • In the Wait box, choose 5 minutes
  • Click On resume, password protect, and then click OK.
share|improve this answer
I have the screensaver. But the funny thing is, when the monitor goes off based on the power management setting, the screensaver stops, which means the password protection under screensaver is also removed. – Anon Jul 3 '13 at 11:18
@Anon - My guess is that you don't have the screensaver set to lock the computer. – Daniel R Hicks Jul 3 '13 at 11:21
@ Daniel, you were absolutely right. The screensaver didn't have the lock on. – Anon Jul 4 '13 at 22:36

For that purpose I've created small AutoIt script. It works in loop, periodically cheking the _Timer_GetIdleTime() function value from Timers.au3, if it becomes greater than certain amount of time, the script executes tsdiscon.exe, and PC exits to welcome screen.

Here is the code I have used:

#include <Timers.au3>

const $setpoint = 900000 ; switch by idle time setpoint 900000 ms = 15 minutes
const $interval = 60000 ; check interval 60000 ms = 1 minute
const $tsdisconpath = "C:\WINDOWS\System32\tsdiscon.exe" ; specify the actual path for your OS, this might need to be changed
; eg on my Win 7 HB x64 the file full path is C:\WINDOWS\winsxs\\tsdiscon.exe

$disconnected = false
$idle = 0
while true
    $prev = $idle
    $idle = _Timer_GetIdleTime()
    if $disconnected and $prev > $idle then ; user has logged in again
        $disconnected = false ; reset state
    if $idle > $setpoint and not $disconnected then
        run($tsdisconpath, "") ; exit to welcome screen
        $disconnected = true
        $idle = 0

You have to specify the actual path to the file tsdiscon.exe for your OS. I compiled this code to exe with Aut2Exe (it available both in full install and portable AutoIt), and put to autorun. AutoIt version was
If you want to exit to the Lock screen instead of Welcome screen, then you use

const $tsdisconpath = "RunDll32.exe user32.dll,LockWorkStation

A fly in an ointment. I have to say about petty drawbacks of the script you may encounter. Usually you do not touch mouse and keyboard while watching movies, so the script will suddenly exit at setpoint, and the movie will continue playback. Also I noticed when I wake up PC after hibernation and log on, for some reason the script detects that time is out, and exits.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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