The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Email Subscription

    Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 717 other subscribers

Archive for June 7th, 2012

Programmatic alternatives to Windows-L keyboard shortcut (SwitchUser / LockWorkstation)

Posted by jpluimers on 2012/06/07

On Windows, the keyboard shortcut [WayBack] Windows-L will lock your workstation and when [WayBack] Fast User Switching is enabled – and when your (corporate) policies allow it – shows your Switch User screen.

First of all, there is [WayBack] TSDISCON (which I found thanks to [WayBack] this thread). It is meant to disconnect a terminal services session, but when you are logged in on the console, it just locks your workstation.

It is small (about 20 kilobyte) and [WayBack] has been there since Windows 2000.

Then there is the [WayBack] LockWorkStation function that does the same.

Lot’s of people think you can call LockWorkStation using rundll32.exe. As per Raymond Chen: [WayBack] (404) Don’t do that: it has a different parameter count and different calling convention than [Archive.is] rundll32.exe expects (note that in Raymond’s article, the last link is broken).

So now you all go upvote [WayBack] the TSDISCON answer and downvote the ruldll32.exe LockWorkStation answers on this [WayBack] SuperUser.com question.

–jeroen

PS: [WayBack] Rob van der Woude published a list of Terminal Server commands including TSDISCON.

Posted in Development, Power User, Scripting, Software Development, Windows, Windows 7, Windows 8, Windows Vista, Windows XP | Leave a Comment »