Using WMI To remotly shutdown a machine

G

Glenn Wilson

Trying to reboot a machine by useing the WMI systems, and
I am having no luck.

Ihave tried it with Domain Admin Account, Local Admin
Account, and still no luck.

I keep getting access denied

Could some one please help to solve this problem.

Code Below.
Imports System.Management

Module Module1

Sub Main()
Dim strComputerName As String = "ADMIN"
Dim objManScope As
System.Management.ManagementScope
Dim objQuery As System.Management.ObjectQuery
Dim objSearcher As ManagementObjectSearcher
Dim colQueryCollection As
ManagementObjectCollection
Dim outParams As ManagementBaseObject
Dim colInstanses As Collection
Dim objInstance As ManagementObject
Dim strWQLQuery As String
Dim intResult As Integer
Dim objArray() As String = {""}

Dim co As New ConnectionOptions
co.Username = "ADMIN\Administrator"
co.Password = "localpass"

strWQLQuery = "select * from
Win32_OperatingSystem " & _
"where Primary = ""True"""

objManScope = New
System.management.ManagementScope("\\" & _
strComputerName & "\root\cimv2", co)
objQuery = New System.Management.ObjectQuery
(strWQLQuery)
objSearcher = New ManagementObjectSearcher
(objManScope, objQuery)
colQueryCollection = objSearcher.Get

For Each objInstance In colQueryCollection
outParams = objInstance.InvokeMethod
("Reboot", objArray)
Next
End Sub

End Module
 
H

Herfried K. Wagner [MVP]

Hello,

Glenn Wilson said:
Trying to reboot a machine by useing the WMI systems, and
I am having no luck.

If you don't get an answer there, feel free to post to this ng:

news://news.microsoft.com/microsoft.public.dotnet.framework.wmi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top