用vbs检查注册表项的访问权限的代码
程序员文章站
2022-07-04 20:42:55
const key_query_value = &h0001 const key_set_value = &h0...
const key_query_value = &h0001
const key_set_value = &h0002
const key_create_sub_key = &h0004
const delete = &h00010000
const hkey_local_machine = &h80000002
strcomputer = "."
set stdout = wscript.stdout
set oreg=getobject("winmgmts:{impersonationlevel=impersonate}!\\" &_
strcomputer & "\root\default:stdregprov")
strkeypath = "system\currentcontrolset"
oreg.checkaccess hkey_local_machine, strkeypath, key_query_value, bhasaccessright
if bhasaccessright = true then
stdout.writeline "have query value access rights on key"
else
stdout.writeline "do not have query value access rights on key"
end if
oreg.checkaccess hkey_local_machine, strkeypath, key_set_value, bhasaccessright
if bhasaccessright = true then
stdout.writeline "have set value access rights on key"
else
stdout.writeline "do not have set value access rights on key"
end if
oreg.checkaccess hkey_local_machine, strkeypath, key_create_sub_key, bhasaccessright
if bhasaccessright = true then
stdout.writeline "have create subkey access rights on key"
else
stdout.writeline "do not have create subkey access rights on key"
end if
oreg.checkaccess hkey_local_machine, strkeypath, delete, bhasaccessright
if bhasaccessright = true then
stdout.writeline "have delete access rights on key"
else
stdout.writeline "do not have delete access rights on key"
end if
const key_set_value = &h0002
const key_create_sub_key = &h0004
const delete = &h00010000
const hkey_local_machine = &h80000002
strcomputer = "."
set stdout = wscript.stdout
set oreg=getobject("winmgmts:{impersonationlevel=impersonate}!\\" &_
strcomputer & "\root\default:stdregprov")
strkeypath = "system\currentcontrolset"
oreg.checkaccess hkey_local_machine, strkeypath, key_query_value, bhasaccessright
if bhasaccessright = true then
stdout.writeline "have query value access rights on key"
else
stdout.writeline "do not have query value access rights on key"
end if
oreg.checkaccess hkey_local_machine, strkeypath, key_set_value, bhasaccessright
if bhasaccessright = true then
stdout.writeline "have set value access rights on key"
else
stdout.writeline "do not have set value access rights on key"
end if
oreg.checkaccess hkey_local_machine, strkeypath, key_create_sub_key, bhasaccessright
if bhasaccessright = true then
stdout.writeline "have create subkey access rights on key"
else
stdout.writeline "do not have create subkey access rights on key"
end if
oreg.checkaccess hkey_local_machine, strkeypath, delete, bhasaccessright
if bhasaccessright = true then
stdout.writeline "have delete access rights on key"
else
stdout.writeline "do not have delete access rights on key"
end if
上一篇: VBS 生成不重复随机数代码[0-10]