我正在 VBA 中编写一个脚本,它将监视注册表值,如果它更改脚本将覆盖它。到目前为止,我编写了一个脚本来检查注册表中的值并将其更新为给定值。但我的问题是如何每 2 分钟或值更改时更新注册表?请帮忙 !!!
On Error Resume Next
HKEY_CURRENT_USER = &H80000001
strComputer = "."
Set objReg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "Control Panel\Desktop"
ValueName = "ScreenSaveActive"
objReg.GetStringValue HKEY_CURRENT_USER, strKeyPath, ValueName, strValue
objReg.CreateKey HKEY_CURRENT_USER, strKeyPath
If IsNull(strValue) Then
Wscript.Echo "The value is either Null or could not be found in the registry."
Else
Wscript.Echo "Value: ", strValue
strValue = "1"
objReg.SetStringValue HKEY_CURRENT_USER, strKeyPath, ValueName, strValue
Wscript.Echo "Value after change ", strValue
End If
问候, 厄尼