description | ms.assetid | ms.tgt_platform | title | ms.topic | ms.date | topic_type | api_name | api_type | api_location | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
You can use the AddAsString method of the SWbemPrivilegeSet object to add a privilege to an SWbemPrivilegeSet collection using a privilege string. |
729ed4e3-2c5c-4bb4-acc6-cf9ad0d5eaf1 |
multiple |
SWbemPrivilegeSet.AddAsString method (Wbemdisp.h) |
reference |
05/31/2018 |
|
|
|
|
You can use the AddAsString method of the SWbemPrivilegeSet object to add a privilege to an SWbemPrivilegeSet collection using a privilege string. Use this method to add a privilege or to enable a privilege for SWbemSecurity objects. See Executing Privileged Operations Using VBScript.
For an explanation of this syntax, see Document Conventions for the Scripting API.
objPrivilege = .AddAsString( _
ByVal strPrivilege, _
[ ByVal bIsEnabled ] _
)
-
strPrivilege
-
Required. One of the privilege strings. For a complete list of these strings and the associated WMI constants, see Privilege Constants. Every privilege string represents a specific privilege. For example, to add the privilege that use to shut down a computer system, use the SeShutdownPrivilege string.
-
bIsEnabled [optional]
-
Boolean value that enables or disables this privilege. The default value is True.
If successful, this method returns an SWbemPrivilege object that represents the new privilege. Otherwise, a null object is returned.
Upon the completion of the AddAsString method, the Err object may contain the error code in the following list.
-
wbemErrFailed - 2147749889 (0x80041001)
-
Unspecified error.
The following VBScript code example creates a new port for a print server using Win32_TCPIPPrinterPort. The SeLoadDriverPrivilege is required for this operation. See Executing Privileged Operations.
Set objWMIService = GetObject("Winmgmts:")
objWMIService.Security_.Privileges. _
AddAsString "SeLoadDriverPrivilege", True
Set objNewPort = objWMIService.Get _
("Win32_TCPIPPrinterPort").SpawnInstance_
objNewPort.Name = "IP_111.222.111.11"
objNewPort.Protocol = 1
objNewPort.HostAddress = "111.222.111.11"
objNewPort.PortNumber = "9999"
objNewPort.SNMPEnabled = False
objNewPort.Put_
A code example using this method is also described in the SWbemPrivilegeSet topic.
Requirement | Value |
---|---|
Minimum supported client |
Windows Vista |
Minimum supported server |
Windows Server 2008 |
Header |
|
Type library |
|
DLL |
|
CLSID |
CLSID_SWbemPrivilegeSet |
IID |
IID_ISWbemPrivilegeSet |