我看过谷歌如何将其转换为VB.net甚至尝试使用WMI代码工具编写自己的。我正在尝试LOGOFF远程计算机。关机-l与/ m一起工作。这是当前工作的VBS脚本。有人可以告诉我如何转换为VB.net吗?
strComputer= InputBox( "Enter Machine Name/IP Address here..." )
Set objWMI = GetObject("winmgmts:{(Shutdown)}\\" + strComputer + "\root\cimv2")
Set colOperatingSystems = objWMI.ExecQuery("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
ObjOperatingSystem.Win32Shutdown(0)
Next
我尝试了从WMI代码创建者生成的以下内容:
Dim scope As New ManagementScope( _
"\\192.168.1.105\root\CIMV2")
scope.Connect()
Dim classInstance As New ManagementObject(scope, _
New ManagementPath("Win32_OperatingSystem.ReplaceKeyPropery='ReplaceKeyPropertyValue'"), _
Nothing)
' Obtain [in] parameters for the method
Dim inParams As ManagementBaseObject = _
classInstance.GetMethodParameters("Win32Shutdown_OperatingSystem")
' Add the input parameters.
inParams("Flags") = 4
' Execute the method and obtain the return values.
Dim outParams As ManagementBaseObject = _
classInstance.InvokeMethod("Win32Shutdown_OperatingSystem", inParams, Nothing)