Locking two Windows 7 Workstations

1

So here's the story; At work I have two computers. Both Windows 7 and on the same network.

I've used the shortcut trick to create shortcuts on both computers that lock them when I leave.

rundll32.exe User32.dll,LockWorkStation

I was wondering though if there was a way to modify the shortcut or create a .bat file on my "main" workstation that would allow me to lock both stations.

I've googled a few times for a solution, but most results just lead back to instructions on creating the 'standard' shortcut I mentioned above, or a similar question asked on Stackoverflow, where installing 3rd party software is suggested.

Dex Luther

Posted 2016-01-20T19:41:42.300

Reputation: 23

Are these computer linked together in some capacity ( i.e. connected tot he same domain )? – Ramhound – 2016-01-20T19:51:42.343

If both workstations are part of domain and your user has all required permission than it appears that this can be achieved using little VB script. This old post on MSFT Scripting guy has instructions for just about that. http://blogs.technet.com/b/heyscriptingguy/archive/2004/11/15/can-i-lock-a-workstation-using-a-script.aspx (Word of caution: I have not tried it personally)

– JackLock – 2016-01-20T20:32:34.650

Ramhound, Yes, both computers are part of the same network and domain. – Dex Luther – 2016-01-21T22:59:23.003

Danger! rundll32 is not an officially supported way to invoke Windows API functions. For this application, use tsdiscon. – Ben N – 2016-01-22T00:25:51.133

Answers

0

It could be a tough task without installing additional additional software: you have to have something listening to your commands on another computer.

Unfortunately shutdown command does not support locking the workstation.

If you have PowerShell on both computers, you can try to use its remote features. To Run a Script:

invoke-command -computername Server01 -filepath C:\Scripts\LockWorkstation.bat

As another option, you can try to use PsExec utility from PsTools:

psexec \\Server01 cmd /c C:\Scripts\LockWorkstation.bat

I have tested neither approaches myself, just give you some ideas.

Alexey Ivanov

Posted 2016-01-20T19:41:42.300

Reputation: 3 900