in

ASP.NET Weblogs

Brian Desmond's Blog

Inherits Network.Admin
Implements IOneManBand

Shortcut to Lock Computer on Win2k

Tim posted a list of handy Windows keyboard shortcuts. Someone pointed out in his comments that some of these don't work on all versions of Windows, such as Win + L which will lock your machine on XP & 2003, but not 2000.

Fortunately, this particular shortcut is easy enough to fix! Create a new shortcut on your desktop, hard drive, or elsewhere. Set this shortcut to run “rundll32 user32,LockWorkStation”. Once the shortcut is created, right click it, goto properties, click in the Shortcut Key text box, and press Win + L. Win + L will now lock your machine.

EDIT: Raymond Chen tells me I shouldn't be doing this rundll32 trick. I've never had it fail on me, and I don't exactly understand what would cause it to, so all I can say, while this trick works, one of the guru's behind Windows says don't use it., so, use the LockWorkStation entrypoint at your own discretion.

Published Dec 11 2003, 10:24 PM by bdesmond
Filed under:

Comments

 

Ron Krauter said:

You are a bad man! Thanks for the tip.
December 12, 2003 12:04 AM
 

Raymond Chen said:

Please don't do this. The LockWorkStation function was not designed to be run via Rundll32. To be run via Rundll32 a function needs to match a very specific function signature, which LockWorkStation doesn't. As a result, the stack is misaligned on return and what happens next is anybody's guess.

I'm severely tempted to fix Longhorn so it enforces the function call signature strictly for Rundll32 - people are abusing it pretty badly.
December 12, 2003 1:52 AM
 

dvz said:

Perhaps Raymond or someone could make a constructive suggestion as to what to use instead of rundll32 then.
If something is broken (win2k), and a workaround is found (rundll32), either fix the original problem or get an acceptable workaround. Don't just say "don't do it", and then try to stop people.
Raymond is not addressing the real problem.
January 15, 2004 4:03 AM
 

TrackBack said:

January 15, 2004 11:03 AM
 

asdf said:

// Use this instead:

#define _WIN32_WINNT 0x0500
#include <windows.h>

int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
LockWorkStation();
return 0;
}
January 15, 2004 1:12 PM
 

asdf said:

Also pushing CTRL+ALT+DEL then pushing enter locks your computer in win2k. Which is much easier and faster to type than WINKEY+L in my opinion.
January 15, 2004 2:00 PM
 

Ben said:

I tried to create the shortcut and it wouldn't allow me to add the keyboard shortcut "Win + L", but it worked fine. Also, if you are not supposed to do this but it worked, could anything serious go wrong with the system by using the rundll32 shortcut.
February 6, 2004 2:27 AM
 

Dave Warren said:

Maybe a valid command line workaround would be a better idea?

As funky as a little bit of code is, that isn't practical for your average end user.

Personally, all I want is to have one of my keyboard keys programmed to lock the workstation. Faster then winkey+L, faster then ctrl-alt-del L, faster then anything else.
February 16, 2004 4:41 AM
 

Stevers said:

Microsoft has an article for this procedure, and windows 2000 is in that list. So they obviously see it as ok.

http://support.microsoft.com/?kbid=314969
February 19, 2004 3:21 PM
 

NoOneInParticular said:

Clearly Raymond Chen doesn't know what the heck he's talking about since this above link to the microsoft support site essentially recommends rundll32 user32,LockWorkStation.

Then again, MS Support could be wrong too... It wouldn't be the first time.

In any case, nice trick! I like it.
April 14, 2004 1:39 PM
 

milbertus said:

I can't speak for anyone else, but I would tend to believe Raymond Chen over Windows Support. Who was it that actually works on Windows again? ;)
April 23, 2004 10:01 PM
 

sasi said:

I want to kow how to enable autolock in win2000 profesiional
May 12, 2004 5:19 AM

Leave a Comment

(required)  
(optional)
(required)  
Add