Remotely Log Off Machine

kyle_denney

New member
Joined
Aug 15, 2012
Messages
2
Programming Experience
1-3
I am trying to remotely log off PC within a network. However, using WMI Code
Creator from Microsoft with this code it does not work.

VB.NET:
Dim connection As New ConnectionOptions                
connection.Username = userNameBox.Text                
connection.Password = passwordBox.Text                
connection.Authority = "ntlmdomain:DOMAINNAME"                
Dim scope As New ManagementScope( _                    
"\\SOMECOMPUTERNAME\root\CIMV2", connection)               
 scope.Connect()               
Dim classInstance As New ManagementClass(scope, _                    
New ManagementPath("Win32_OperatingSystem"), _                    
Nothing)                
' Obtain [in] parameters for the method               
 Dim inParams As ManagementBaseObject = _                    
classInstance.GetMethodParameters("Win32Shutdown")                
' Add the input parameters.                inParams("Flags") =  4                
' Execute the method and obtain the return values.               
 Dim outParams As ManagementBaseObject = _                    
classInstance.InvokeMethod("Win32Shutdown", inParams, Nothing)
 
Last edited:
Back
Top