WMI - cannot create ActiveX object

A

Amadej Bukorovic

I've been trying to write a simple program to remotely reboot a computer but
with little success. It stops with this part
of the code:

Sub RebootComputer(ByVal strComp)
Dim objOSSet, objOS
objOSSet =
GetObject("winmgmts:{impersonationLevel=impersonate,(RemoteShutdown)}//" &
strComp & "/root/cimv2").ExecQuery("select * from Win32_OperatingSystem
where Primary=true")
For Each objOS In objOSSet
objOS.Reboot()
Next
End Sub

When I run the code, the application crashes and the error is: An unhandled
exception of type 'System.Exception' occurred in microsoft.visualbasic.dll
Additional information: Cannot create ActiveX component.

This happens no matter what I try to do, be it reboot a computer remotely or
start a new process on a remote computer.

Can someone tell me what could be the problem and what I am doing wrong :)
Oh, I'm using Visual Studio .NET v2003 .
 
A

Amadej Bukorovic

Thanks. I've already tried that.
My point was that all the code I found fails with the same error ("Cannot
create ActiveX component").

Does the .NET framework have to be installed on the remote system which I
want to access using WMI?
Or am I missing something else (apart from reading that there are problems
in the WMI classes implementation).
 
P

Patrick Steele [MVP]

Thanks. I've already tried that.
My point was that all the code I found fails with the same error ("Cannot
create ActiveX component").

Does the .NET framework have to be installed on the remote system which I
want to access using WMI?
Or am I missing something else (apart from reading that there are problems
in the WMI classes implementation).

I'm not up on WMI, so it could be a platform issue. What OS are you
running the app on and what are the types of OS's you're trying to
remotely reboot?
 

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