' taken from
' http://www.activexperts.com/activmonitor/windowsmanagement/adminscripts/registry/
' computer name we want to modify ("." for local, "pcname" for remote pc, no "\\" needed)
strComputer = "."
' leave these constants
const HKEY_LOCAL_MACHINE = &H80000002
Set StdOut = WScript.StdOut
' connect to the registry on the specified computer
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
StdOut.WriteLine "Changing Registry on " & strComputer
' registry key we want to modify
strKeyPath = "SOFTWARE\MyCompany\"
' create a new key.
' strKeyPath = "SOFTWARE\MyCompany\New registry folder"
' oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath
' write a string value
strValueName = "String Value Name"
strValue = "string value"
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
' write a integer value
strValueName = "DWORD Value Name"
dwValue = 82
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue
为什么不使用 WMI 脚本,使用 cscript.exe 运行。
你试过REG.EXE吗?
REG.EXE 允许您从命令行执行许多注册表操作。当您想在不打开 RegEdit 的情况下快速进行更改时,这可能很有用,它还允许您在登录脚本和批处理文件中嵌入注册表操作。
根据 MS KB831787阻止访问注册表编辑工具策略更改在 Windows XP 和 Windows Server 2003 中您可以在静默模式下运行 regedit,即使在 Windows XP/2003 上,如果您更新 GPO 模板。
从 KB831787,