Link to home
Start Free TrialLog in
Avatar of richelieu7777
richelieu7777

asked on

GetObject("winmgmts:\\.\root\cimv2")

More than one customer of mine is reporting a "Permission Denied" error number 70 when the following lines are executed:

  Dim objWMIService As Object
  Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")

These two lines are called within the "Class_Initialize" function of a class in an ActiveX DLL of mine.

I cannot reproduce this error on any computer I can get my hands on.  Does anyone have any ideas as to:

1)  how I can set up my computer to reproduce this problem?
2)  how I can fix the bug?

Thanks in advance.
Avatar of Erick37
Erick37
Flag of United States of America image

It sounds like a permissions issue.  Perhaps the user does not have sufficient rights on the computer to connect to WMI?
Avatar of richelieu7777
richelieu7777

ASKER

They double checked that they have Administrator rights, the same as me.
ASKER CERTIFIED SOLUTION
Avatar of Erick37
Erick37
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Unfortunately I don't think this is the issue either because the customer *is* able to instantiate other classes in the ActiveX DLL; they just can't instantiate the class that contains the WMI code.
Can they use WMI on the computer at all?  From VBScript for example?
Erick37,

I have never used VBScript; only VB6, C#, C++ 6.0, VBA.  Do you have an example I could use to determine whether they can run a WMI at all?

I can try "Set objWMIService = GetObject("winmgmts:root\default") but again, this would only be in VB6 or VBA.

By the way, I have verified with the customer that even though the COM Security tab had "Allow" for all fields, the problem still existed.

They also report that they get the message "Failed to connect to <local computer> because "Win32: Access is denied." when performing step #4 of the following:

    1. Right-click on My Computer and click Manage.
    2. Double-click Services and Applications and then double-click WMI Control.
    3. Right-click WMI Control and then click Properties.
    4. In the WMI Control Properties dialog box click the Security tab.



SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also what happens if they create a new user account that has admin priveledges and login to that new account and then try to run a wmi script or to use wmi ?
Well the customer is unable to get back with me right away.  But I did find another way to change the WMI permissions:

Control Panel->Administrative Tools
Double click on Component Services
Double click on Component Services in the new window
Double Click on Computers in the right pane
Double click on My Computer in the right pane
Double click on DCOM Config in the right pane
Right click on "Windows Management and Instrumentation" icon in the right pane
Select Properties
Select the "Security" Tab
Select "Customize" for all three frames
Click on all three "Edit" buttons and make sure each checkbox is "Allow"


If "Deny" is selected the "Permissions Denied" error occurs *even though all* the checkboxes of the  Component Services->"My Computer"->"Properties"->[COM Security] tab are all "ALLOW'.

I haven't got a definitive answer from the customer yet as to whether this latest DCOM WMI permission is the cause, but you guys have steered me in the right direction, I believe.  So I would like to split the 500 points between Erick37 and "gecko_au2003".  How do I split the points?  Do I select "Accept" for both answers?


gecko_au2003,

I created the VBS file that you sent me.  But how do I run it?  I tried running it from the DOS prompt, but it didn't work.  Do I run it within VB????
Is VBScript a standalone application?  I have Visual Studio 6.0 Enterprise Edition, but VBScript does not appear to be included.

Is there a place I can download an evaluation copy of VBScript to run this WMI script?
Never mind.  I figured it out.  I *can* run the VBS file from the DOS prompt.  Its just that it was generating an error when I did so.  To fix this I had to put:

              ("Select * from Win32_OperatingSystem")

on the same line as

              Set colItems = objWMIService.ExecQuery

 for it to work.