Forcing a remote logoff

by Mitch Tulloch [Published on 27 Nov. 2007 / Last Updated on 27 Nov. 2007]

How to force a user to log off of a remote machine

Bob logs onto his workstation and you (who are on another workstation) want to force Bob to log off. How can you do that?

You could do it using Computer Management. Open Computer Management on your machine and connect to Bob's computer, then right-click on Bob's computer and select Properties. Switch to the Advanced tab, and click Settings under Startup And Recovery options. Now go to Shutdown and under Action click Log Off Current User and then OK.

Of course some things are easier to do using a script:

strComputer = ""
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery ("SELECT * FROM Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
ObjOperatingSystem.Win32Shutdown(0)
Next

***

Mitch Tulloch is lead author for the Windows Vista Resource Kit from Microsoft Press, which is THE book for IT pros who want to deploy, maintain and support Windows Vista in mid- and large-sized network environments. Mitch is also the author of Introducing Windows Server 2008, the first book from Microsoft Press about the exciting new server platform. For more information on these and other books written by Mitch, see www.mtit.com.

Featured Links