55 lines
1.7 KiB
Plaintext
55 lines
1.7 KiB
Plaintext
' Copyright (c) Microsoft Corporation, All Rights Reserved
|
|
'***************************************************************************
|
|
'
|
|
' WMI Sample Script - Privilege manipulation (VBScript)
|
|
'
|
|
' This script demonstrates how to add privileges using the
|
|
' SWbemPrivilegeSet object.
|
|
'
|
|
'***************************************************************************
|
|
on error resume next
|
|
|
|
const wbemPrivilegeSecurity = 8
|
|
const wbemPrivilegeDebug = 20
|
|
|
|
set locator = CreateObject("WbemScripting.SWbemLocator")
|
|
|
|
' Add a single privilege using SWbemPrivilegeSet.Add
|
|
|
|
locator.Security_.Privileges.Add wbemPrivilegeSecurity
|
|
Set Privilege = locator.Security_.Privileges(wbemPrivilegeSecurity)
|
|
WScript.Echo Privilege.Name
|
|
|
|
' Attempt to add an illegal privilege using SWbemPrivilegeSet.Add
|
|
locator.Security_.Privileges.Add 6535
|
|
if err <> 0 then
|
|
WScript.Echo "0x" & Hex(Err.Number), Err.Description, Err.Source
|
|
err.clear
|
|
end if
|
|
|
|
locator.Security_.Privileges.Add wbemPrivilegeDebug
|
|
|
|
locator.Security_.Privileges(wbemPrivilegeDebug).IsEnabled = false
|
|
|
|
' Add a single privilege using SWbemPrivilegeSet.AddAsString
|
|
|
|
Set Privilege = locator.Security_.Privileges.AddAsString ("SeChangeNotifyPrivilege")
|
|
WScript.Echo Privilege.Name
|
|
|
|
' Attempt to add an illegal privilege using SWbemPrivilegeSet.AddAsString
|
|
locator.Security_.Privileges.AddAsString "SeChungeNotifyPrivilege"
|
|
if err <> 0 then
|
|
WScript.Echo "0x" & Hex(Err.Number), Err.Description, Err.Source
|
|
err.clear
|
|
end if
|
|
|
|
WScript.Echo ""
|
|
for each Privilege in locator.Security_.Privileges
|
|
WScript.Echo "[" & Privilege.DisplayName & "]", Privilege.Identifier, Privilege.Name, Privilege.IsEnabled
|
|
next
|
|
|
|
if err <> 0 then
|
|
WScript.Echo Err.Number, Err.Description, Err.Source
|
|
end if
|
|
|