M
Mark-Allen Perry
To all:
The code below checks to see if the user account running the script has the
specified permissions; in this case, QUERY_VALUE.
What I would like is a similar code example on how to ask if a 'specified
user or group' has a specific permission. Does anyone know of a code
example that will do this? Or can post a link to a URL somewhere. I've
checked all over MS and MSDN, and on Google but after checking about 100
sites, nothing looks promising.
'---------------------------------------------------------------------------
------
' Create constants for access rights and registry hive
const KEY_QUERY_VALUE = &H0001
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
strKeyPath = "SYSTEM\CurrentControlSet"
' Does the account under which the script runs have the
' right to query the SYSTEM\CurrentControlSet key
'---------------------------------------------------------------
objReg.CheckAccess HKEY_LOCAL_MACHINE, strKeyPath, KEY_QUERY_VALUE,
bHasAccessRight
If bHasAccessRight = True Then
Wscript.Echo "Has Query Value Access Rights on
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet"
Else
Wscript.Echo "No Query Value Access Rights on
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet"
End If
'---------------------------------------------------------------------------
------
There are example for using WMI for checking the DACLs of file objects;
files and folders. But I haven't been able to find something similar for
Regsitry keys.
many thanks for all the help,
The code below checks to see if the user account running the script has the
specified permissions; in this case, QUERY_VALUE.
What I would like is a similar code example on how to ask if a 'specified
user or group' has a specific permission. Does anyone know of a code
example that will do this? Or can post a link to a URL somewhere. I've
checked all over MS and MSDN, and on Google but after checking about 100
sites, nothing looks promising.
'---------------------------------------------------------------------------
------
' Create constants for access rights and registry hive
const KEY_QUERY_VALUE = &H0001
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
strKeyPath = "SYSTEM\CurrentControlSet"
' Does the account under which the script runs have the
' right to query the SYSTEM\CurrentControlSet key
'---------------------------------------------------------------
objReg.CheckAccess HKEY_LOCAL_MACHINE, strKeyPath, KEY_QUERY_VALUE,
bHasAccessRight
If bHasAccessRight = True Then
Wscript.Echo "Has Query Value Access Rights on
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet"
Else
Wscript.Echo "No Query Value Access Rights on
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet"
End If
'---------------------------------------------------------------------------
------
There are example for using WMI for checking the DACLs of file objects;
files and folders. But I haven't been able to find something similar for
Regsitry keys.
many thanks for all the help,