VBS到VB.NET的转换
我在google上到处寻找如何将其转换为VB.net,甚至尝试使用WMI代码工具编写自己的代码。我正在尝试注销远程计算机。关机-l不与/m一起工作。下面是当前工作的VBS脚本。有人能告诉我如何转换到VB.net吗VBS到VB.NET的转换,vb.net,vbscript,wmi,Vb.net,Vbscript,Wmi,我在google上到处寻找如何将其转换为VB.net,甚至尝试使用WMI代码工具编写自己的代码。我正在尝试注销远程计算机。关机-l不与/m一起工作。下面是当前工作的VBS脚本。有人能告诉我如何转换到VB.net吗 strComputer= InputBox( "Enter Machine Name/IP Address here..." ) Set objWMI = GetObject("winmgmts:{(Shutdown)}\\" + strComputer + "\root\cimv2"
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)
这不是代码翻译服务。下载WMI Code Creator实用程序,它可以在VB.NET和C中自动生成所需的代码。这就是我寻求帮助的原因。我之前也说过我在WMI代码创建者中尝试过这个,但它没有执行注销,没有错误,只是不起作用