将多字符串值添加到注册表 [英] Add Multi String value to the registry
本文介绍了将多字符串值添加到注册表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
此代码是更大应用程序的一部分.它旨在向注册表添加新的多字符串值.我已经搜索了整个网络,但无法找到工作的解决方案.
This code is part of a bigger application. It is designed to add anew Multi String value to the registry. I have searched all over the net and cannot get a solution to work.
我可以使用 DOS 命令执行此操作,但使用 VBScript 似乎无法执行此操作.
I can do this with a DOS command but cannot seem to do it with VBScript.
这是我发现的 VBScrip,据说可以工作.
This is the VBScrip I have found which supposedly works.
' Create a MultiString Value in the registry.
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")
strKeyPath = "SYSTEM\CurrentControlSet\services\WebClient\Parameters"
strValueName = "AuthForwardServerList"
arrStringValues = Array("*.server1.com", "*.server2.com")
oReg.SetMultiStringValue HKEY_LOCAL_MACHINE,strKeyPath, _
strValueName,arrStringValues
提前致谢.
推荐答案
您需要以管理员身份运行脚本.
You need to run your script as administrator.
如果您像这样检查 SetMultiStringValue
返回值:
res = oReg.SetMultiStringValue(HKEY_LOCAL_MACHINE, strKeyPath, strValueName, arrStringValues)
WScript.Echo res
你在非提升模式下得到 5,意思是访问被拒绝"(见 MSDN 中的系统错误代码).
you get 5 in non-elevated mode, meaning "Access is denied" (see System Error Codes in MSDN).
这篇关于将多字符串值添加到注册表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文