#87639 - 2002-09-04 10:15 PM
Use WMI to Check Registry Access Permissions
|
Chris S.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
I'd like some opinions before I submit this to the UDF forum.
code:
Break On CLS
If CheckAccess(,"System\CurrentControlSet\Services\LanmanServer\Parameters","qs") = 0 "User has Query and Set Value permissions." ? Else "User cannot write to this key." ? Endif
;Q = KEY_QUERY_VALUE ;S = KEY_SET_VALUE ;C = KEY_CREATE_SUB_KEY ;E = KEY_ENUMERATE_SUB_KEYS ;N = KEY_NOTIFY ;L = KEY_CREATE_LINK ;D = DELETE ;R = READ_CONTROL ;W = WRITE_DAC ;O = WRITE_OWNER
Function CheckAccess(Optional $Key, $Path, Optional $Access, Optional $strComputer) Select Case $Key = "HKEY_CLASSES_ROOT" $Key = &80000000 Case $Key = "HKEY_CURRENT_USER" $Key = &80000001 Case $Key = "HKEY_LOCAL_MACHINE" $Key = &80000002 Case $Key = "HKEY_USERS" $Key = &80000003 Case $Key = "HKEY_CURRENT_CONFIG" $Key = &80000005 Case $Key = "HKEY_DYN_DATA" $Key = &80000006 Case 1 $Key = &80000002 EndSelect If instr($Access, "Q") $Perms = $Perms + &1 Endif If instr($Access, "S") $Perms = $Perms + &2 Endif If instr($Access, "C") $Perms = $Perms + &4 Endif If instr($Access, "E") $Perms = $Perms + &8 Endif If instr($Access, "N") $Perms = $Perms + &10 Endif If instr($Access, "L") $Perms = $Perms + &20 Endif If instr($Access, "D") $Perms = $Perms + &10000 Endif If instr($Access, "R") $Perms = $Perms + &20000 Endif If instr($Access, "W") $Perms = $Perms + &40000 Endif If instr($Access, "O") $Perms = $Perms + &80000 Endif
If $strComputer = "" $strComputer = "." Endif $objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" + $strComputer + "\root\default:StdRegProv") $CheckAccess = $objRegistry.CheckAccess($Key, $Path, $Perms) EndFunction
|
|
Top
|
|
|
|
#87643 - 2002-09-05 10:30 PM
Re: Use WMI to Check Registry Access Permissions
|
Chris S.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
Well, that's all the endorsement I need then.
I'll look at the other registry functions of WMI as well when I get time. Can probably come up with a way to set values on remote PC's using 'admin' scripts.
|
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 2220 anonymous users online.
|
|
|