我一直在尝试使用VBScript来更改HKEY_USERS中的DWORD值。它可以找到价值并告诉我它是什么,但它不会改变价值。
Const HKEY_USERS = &H80000003
strComputer = "."
Set oReg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = ".DEFAULT\Software\Microsoft\Office\Outlook\Addins\Flowscape.Outlook.AddIn"
strValueName = "LoadBehavior"
oReg.SetDWORDValue HKEY_USERS, strKeyPath, strValueName, 3
If Err = 0 Then
oReg.GetDWORDValue HKEY_USERS, strKeyPath, strValueName, dwValue
WScript.Echo "HKEY_USERS\...\LoadBehavior is set to " & dwValue
Else
WScript.Echo "Error changing dword value" & Err.Number
End If
另一个用于更改HKEY_CURRENT_USER中的DWORD值的脚本可以正常工作。
Const HKEY_CURRENT_USER = &H80000001
strComputer = "."
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Office\Outlook\Addins\Flowscape.Outlook.AddIn"
strValueName = "LoadBehavior"
oReg.SetDWORDValue HKEY_CURRENT_USER, strKeyPath, strValueName, 3
If Err = 0 Then
oReg.GetDWORDValue HKEY_CURRENT_USER, strKeyPath, strValueName, dwValue
WScript.Echo "HKEY_CURRENT_USER\...\LoadBehavior set to " & dwValue
Else
WScript.Echo "Error changing dword value" & Err.Number
End If