vbs 如何判断某个注册表的值是否存在?
答案:2 悬赏:20
解决时间 2021-02-11 20:37
- 提问者网友:白柏唇蜜
- 2021-02-11 15:28
vbs 如何判断某个注册表的值是否存在?
最佳答案
- 二级知识专家网友:悲观垃圾
- 2021-02-11 17:04
set ws=createobject("wscript.shell")
on error resume next
a=ws.regread("HKEY_LOCAL_MACHINE\***\xxx")
if err.number<>0 then
msgbox "注册表值 HKEY_LOCAL_MACHINE\***\xxx 不存在,单击“确定”写入。"
err.clear
ws.regwrite "HKEY_LOCAL_MACHINE\***\xxx",1,"REG_DWORD"
if err.number<>0 then msgbox "写入失败。",16
else
msgbox "注册表值 HKEY_LOCAL_MACHINE\***\xxx 的值为 " & a
end if
on error resume next
a=ws.regread("HKEY_LOCAL_MACHINE\***\xxx")
if err.number<>0 then
msgbox "注册表值 HKEY_LOCAL_MACHINE\***\xxx 不存在,单击“确定”写入。"
err.clear
ws.regwrite "HKEY_LOCAL_MACHINE\***\xxx",1,"REG_DWORD"
if err.number<>0 then msgbox "写入失败。",16
else
msgbox "注册表值 HKEY_LOCAL_MACHINE\***\xxx 的值为 " & a
end if
全部回答
- 1楼网友:瘾与深巷
- 2021-02-11 18:34
on error resume next
dim operationregistry,value
set operationregistry = createobject("wscript.shell")
value = operationregistry.regread("hkey_classes_root\...\aaa")
if (value = 1) then
msgbox "hkey_classes_root\...\aaa的值为1",4160,"结果"
else
msgbox "hkey_classes_root\...\aaa的值不为1",4160,"结果"
operationregistry.regwrite "hkey_classes_root\...\aaa",1,"reg_binary"
end if
set operationregistry = nothing
wscript.quit
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯