Microsoft KB Archive/891865

= FIX: You receive a &quot;Privilege not held&quot; error message when you execute WMI operations by using the System.Management namespace in the .NET Framework 1.1 Service Pack 1 =

Article ID: 891865

Article Last Modified on 12/3/2007

-

APPLIES TO


 * Microsoft .NET Framework 1.1 Service Pack 1

-





SYMPTOMS
Consider the following scenario. You are running a Microsoft .NET Framework-based application in the .NET Framework 1.1 Service Pack 1 (SP1). You execute some Windows Management Instrumentation (WMI) operations that require privileges to be enabled. For example, you shut down or restart a local computer by using the System.Management namespace. Or, you may call the ManagementEventWatcher.Start method.

In this scenario, you receive the following error message:

An unhandled exception of type 'System.Management.ManagementException' occurred in system.management.dll Additional information: Privilege not held.

This behavior only occurs on a local computer. This behavior can occur even if the ConnectionOptions.EnablePrivileges property is set to True.



RESOLUTION
A supported hotfix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Only apply it to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next .NET Framework 1.1 service pack that contains this hotfix.

To resolve this problem immediately, contact Microsoft Product Support Services to obtain the hotfix. For a complete list of Microsoft Product Support Services telephone numbers and information about support costs, visit the following Microsoft Web site:

http://support.microsoft.com/contactus/?ws=support

Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.

The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.   Date         Time   Version        Size    File name ---  07-Jan-2005  04:46  1.1.4322.2062  32,256  Wminet_utils.dll



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the &quot;Applies to&quot; section.



Steps to reproduce the behavior
To reproduce this problem, build and then run the following Microsoft Visual Basic .NET code example on a Microsoft Windows XP-based computer that has the .NET Framework 1.1 Service Pack 1 (SP1) installed. Imports System.Management

Module Module1

Sub Main Dim result As Int32 result = 0 Dim scope As New Management.ManagementScope(&quot;\\.\root\cimv2&quot;)

scope.Options.EnablePrivileges = True scope.Connect Dim objQuery As New System.Management.ObjectQuery(&quot;SELECT * FROM Win32_OperatingSystem&quot;)

Dim objSearcher As New Management.ManagementObjectSearcher(scope, objQuery)

Dim objCol As Management.ManagementObjectCollection = objSearcher.Get Dim mo As Management.ManagementObject For Each mo In objCol

Dim methodArgs As String = {&quot;6&quot;, &quot;0&quot;} //Forced Reboot

mo.InvokeMethod(&quot;Win32Shutdown&quot;, methodArgs)

Console.WriteLine(mo.ToString)

Next

End Sub

End Module You will receive the error message that is mentioned in the &quot;Symptoms&quot; section.

