Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking for a software for Windows XP or a mechanism within Windows XP that will allow me to automatically lock Windows (same effect as WinKey + L) at a given time (e.g. at 3:30 pm) or after certain timer expires (e.g. 15 minutes).

I'm going to take an interview and the interviewee will be assigned fixed amount of time to solve some programming problems with PC. I like the PC to be locked after that time has elapsed.


share|improve this question
up vote 4 down vote accepted

While logged in as an administrator, open a command prompt. Use the at command to create a scheduled task to lock the computer. The command to lock the computer is rundll32.exe user32.dll, LockWorkStation.

For example, at 13:56 /next:monday "rundll32.exe user32.dll, LockWorkStation" would cause the workstation to lock at 1:56 PM next Monday.

If you don't have administrative access needed for the at command, you can add a scheduled task in the control panel to do the same thing.

share|improve this answer
unfortunately i'm not the admin of the pc. this seems doesn't work at non-admin pc. – Donotalo Aug 18 '10 at 8:07
rundll32.exe user32.dll, LockWorkStation should work as a non-admin but at won't. So, why not try sticking rundll32.exe user32.dll, LockWorkStation in to a scheduled task via Control Panel - users can create tasks local to thier account without needing admin rights. – DMA57361 Aug 18 '10 at 11:12
Ah, I had assumed you had admin access, so I didn't originally include the control panel method in my answer. Updated the answer; thanks @DMA57361. – nhinkle Aug 18 '10 at 18:38
For some unknown reason I cannot set a scheduled task to lock the workstation. Here is what I've put into the Run field of advanced property of the scheduled task: "C:\WINDOWS\system32\rundll32.exe user32.dll, LockWorkStation". I've also provided username and password. What am I missing? – Donotalo Aug 23 '10 at 6:37
You put the quotes in the wrong place. You need quotes around the path, but not around the arguments. It should be "C:\WINDOWS\system32\rundll32.exe" user32.dll, LockWorkStation. Right now you're trying to run a file named "rundll32.exe user32.dll, LockWorkStation" in the system32 folder; you want to run the rundll32.exe file with the arguments user32.dll, LockWorkStation. Make sense? – nhinkle Aug 23 '10 at 7:13

The Windows command line tool has a command called "SHUTDOWN" which on Windows 7 at least has the option to log off rather than shutting down the computer. Fortunately it seems this is also in Windows XP!

Shutdown command

You would need to have something schedule the machine to shut down after 15 minutes, I would not recommend using the Windows Scheduler or the command line "AT" command as in my experience these are unreliable.

If you have any programming skills then create a simple program which determines when 15 minutes have passed and issues the command line SHUTDOWN command.

share|improve this answer
Why the scheduler will be less reliable than self-written application? – whitequark Aug 18 '10 at 7:43
force logging off seems aggressive. the interviewee may not save his/her last edit. – Donotalo Aug 18 '10 at 8:08
@whitequark in my experience the Windows Scheduler works until it doesn't, in my opinion based on years of experience it isn't reliable. @Donotalo surely you would only want to employ people who are capable of managing their time effectively to not still be working when the end of the 15 minutes time is up? 8-) – Richard Aug 18 '10 at 8:48
The shutdown command has a timeout switch, hasn't it? – whitequark Aug 18 '10 at 9:18

There's a shareware that can achieve this: Desktop Lock 7.2.

You can let it automatically lock your computer at any time you specified. (Schedule)

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .