Lock Workstation

Deploying to Windows? Utilizing VB Script execution? This is the place to ask Windows-specific questions.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
alemrantareq
Posts: 203
Joined: Wed Jul 23, 2008 8:46 am

Lock Workstation

Post by alemrantareq » Sat Jun 27, 2009 4:08 pm

Hi everybody,

I need a solution. In windows xp, we can simply lock our workstation by pressing windows logo key + L. Now I want to make an application which will automatically do that after a pre-determined time and the user has no need to press those keys. How to do that?

Pls, help me as soon possible. Thanks in advance...

RRobert
Posts: 151
Joined: Sat Feb 28, 2009 8:20 pm

Post by RRobert » Sat Jun 27, 2009 6:09 pm

Try this:

Code: Select all

set the hideConsoleWindows to true
put shell ("RunDLL32.EXE user32.dll,LockWorkStation")
You could also lock the workstation using VBScript and the command do instead of the function shell.

Code: Select all

On Error Resume Next

Set objShell = CreateObject("Wscript.Shell")
objShell.Run "%windir%\System32\rundll32.exe user32.dll,LockWorkStation"
See also: Hey, Scripting Guy! Can I Lock a Workstation Using a Script?

alemrantareq
Posts: 203
Joined: Wed Jul 23, 2008 8:46 am

Post by alemrantareq » Sun Jun 28, 2009 3:35 am

Thanks a lot RRobert :D

Post Reply