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.

11 Comments

  • You are a bad man! Thanks for the tip.

  • 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.

  • 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.

  • // Use this instead:



    #define _WIN32_WINNT 0x0500

    #include <windows.h>



    int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int)

    {

    LockWorkStation();

    return 0;

    }

  • 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.

  • 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.

  • 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.

  • 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.

  • 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? ;)

  • I want to kow how to enable autolock in win2000 profesiional

  • Here it is years later and the none-MS recommended way of doing it is still all that's available? Someone wrote a little hack to do it but I tend to be suspicious of things like that.

Comments have been disabled for this content.