Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

SWbemPrivilegeSet.Add method

The Add method of the SWbemPrivilegeSet object adds an SWbemPrivilege object to the SWbemPrivilegeSet collection. If a privilege with the same name already exists in the collection, it is replaced.

For an explanation of this syntax, see Document Conventions for the Scripting API.


objPrivilege = .Add( _
  ByVal iPrivilege, _
  [ ByVal bIsEnabled ] _



Required. One of the WMI constants from the WbemPrivilegeEnum group. These constants are essentially integers that represent specific privileges. For example, to add the privilege that allows you to shut down a computer system, use the wbemPrivilegeShutdown constant. In a script, you must use the numeric equivalent of 23 (0x17). For a complete list of these constants and the associated privilege strings, see Privilege Constants.

bIsEnabled [optional]

Boolean value that enables or disables this privilege. The default value is TRUE.

Return value

If successful, the method returns an SWbemPrivilege object that represents the new privilege. Otherwise, a null object is returned.

Error codes

Upon the completion of the Add method, the Err object may contain the error code in the following table.

Error (Name/Dec/Hex)Meaning
2147749889 (0x80041001)

Unspecified error.


For a VBScript code example, see SWbemPrivilegeSet. For other script examples, see WMI Tasks for Scripts and Applications and the TechNet ScriptCenter Script Repository.


Minimum supported client

Windows XP

Minimum supported server

Windows Server 2003

Type library




See also

Executing Privileged Operations
Executing Privileged Operations Using VBScript
Privilege Constants



Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft. All rights reserved.