星期四, 九月 14, 2006

(VB.NET)从新启动远程计算机:(需要权限)

Imports System

Imports System.Management

Module Module1

Public Sub Main()

Dim co As ConnectionOptions = New ConnectionOptions

co.Username = "Admin" '登录的用户名称

co.Password = "12345678" 'Password

Dim ms As System.Management.ManagementScope = New System.Management.ManagementScope ("\\192.168.1.2\root\cimv2", co)

Dim oq As System.Management.ObjectQuery = New System.Management.ObjectQuery ("SELECT * FROM Win32_OperatingSystem")

Dim mos As ManagementObjectSearcher = New ManagementObjectSearcher(ms, oq)

Dim _query As ManagementObjectCollection = mos.Get()

Dim mo As ManagementObject

For Each mo In _query

Dim tmp() As String = {"" }

mo.InvokeMethod("Reboot", tmp)

Console.WriteLine(mo.ToString())

Next

End Sub

End Module

没有评论: