Problem : Lock and Unlock workstation programatically via VB.NET

Problem : Lock and Unlock workstation programatically via VB.NET

I’m trying to build a VB.NET program that can lock or unlock the local computer’s desktop (e.g. the equivalent of windows key+L).

It’s easy enough to *lock* the desktop. There’s lots of scripts to do that, e.g.
rundll32.exe user32.dll,LockWorkStation

If VB.NET has a managed way, I’d like to hear it though.

But how do I UNLOCK the desktop later? Assume the program will be running at the time the desktop is locked, the user has administrative rights, and the program already knows the username/password of the logged in user. Also you can assume that the “require ctrl+alt+del to login” feature is disabled, since I’m sure that feature exists SPECIFICALLY to block what i’m trying to do, so lets say it is turned off and the flashy windows xp logon interface is being used.


Solution: Lock and Unlock workstation programatically via VB.NET

Imports System.ComponentModel
Imports System.Runtime.InteropServices
Public Class Form1
Private Shared Function LockWorkStation() As ool)> Boolean
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Not LockWorkStation() Then
Throw New Win32Exception()
End If
End Sub
End Class

The main problem is… “But how do I UNLOCK the desktop later? ”
You can not bypass the alt+ctr+del but you can manipulate windows…
take a look at http://www.codeproject.com/KB/system/RemoteUnlock.aspx