[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
回复 60# powerbat


    很感谢您,最后请求了

另外:
Hive = "HKEY_LOCAL_MACHINE"
KeyPath = "Software\333"
ValueName = "444"
shuzhi =29
gaiwei =20
这样的话
    if CStr(Value)="29" then
        ws.Popup "注册表值变成了29", 3, "通知"
        ws.RegWrite Hive&"\"&KeyPath&"\"&ValueName, 20, "REG_DWORD"
这里该如何修改呢?
如果想同时这样监视2个数值的话,不知道如何添加代码?
最后的求助了实在不好意思,完美后我就关闭问题了

TOP

另外一个数值的注册表路径是什么?

TOP

本帖最后由 wh1234567 于 2012-6-11 14:14 编辑

回复 62# powerbat


    另外一个数值的注册表路径是:
Hive2 = "HKEY_LOCAL_MACHINE"
KeyPath2 = "Software\2012"
ValueName2 = "0610"
shuzhi2 =98(这里是指要监视的数值)
gaiwei2 =70(这里是指要修改为的数值)

TOP

  1. Hive = "HKEY_LOCAL_MACHINE"
  2. KeyPath = "Software\333"
  3. ValueName = "444"
  4. shuzhi = 29
  5. gaiwei = 20
  6. Hive2 = "HKEY_LOCAL_MACHINE"
  7. KeyPath2 = "Software\2012"
  8. ValueName2 = "0610"
  9. shuzhi2 = 98
  10. gaiwei2 = 70
  11. strTitle = "注册表监视"
  12. nShowTime = 3
  13. WQL = "Select * from RegistryValueChangeEvent Where (" & _
  14.     "Hive = '"&Hive&"' and " & _
  15.     "KeyPath = '"&Replace(KeyPath,"\","\\")&"' and " & _
  16.     "ValueName = '"&ValueName&"') OR (" & _
  17.     "Hive = '"&Hive2&"' and " & _
  18.     "KeyPath = '"&Replace(KeyPath2,"\","\\")&"' and " & _
  19.     "ValueName = '"&ValueName2 & "') "
  20. Set ws = CreateObject("WScript.Shell")
  21. CheckReg ValueName
  22. CheckReg ValueName2
  23. Set Sink = WScript.CreateObject("WbemScripting.SWbemSink", "SINK_")
  24. Set objWMIServices = GetObject("winmgmts:" & _
  25.     "{impersonationLevel=impersonate}!\\.\root\default")
  26. objWMIServices.ExecNotificationQueryAsync Sink, WQL
  27. ws.Popup "Listening for Registry Change Events...", nShowTime, strTitle, 4096
  28. Do : WScript.Sleep 1000 : Loop
  29. Sub SINK_OnObjectReady(wmiObject, wmiAsyncContext)
  30.     'WScript.Echo wmiObject.GetObjectText_()
  31.     CheckReg wmiObject.ValueName
  32. End Sub
  33. Sub CheckReg(VName)
  34.   On Error Resume Next
  35.   RegFullPath = Hive & "\" & KeyPath & "\" & ValueName
  36.   RegFullPath2 = Hive2 & "\" & KeyPath2 & "\" & ValueName2
  37.   if VName=ValueName then
  38.       Value = ws.RegRead(RegFullPath)
  39.       if Err then
  40.         ws.RegWrite RegFullPath, gaiwei, "REG_DWORD"
  41.         Err.Clear
  42.       end if
  43.       if CStr(Value)=CStr(shuzhi) then
  44.         ws.Popup RegFullPath & " 变成了 " & shuzhi, nShowTime, strTitle, 4096
  45.         ws.RegWrite RegFullPath, gaiwei, "REG_DWORD"
  46.       end if
  47.   end if
  48.   if VName=ValueName2 then
  49.       Value = ws.RegRead(RegFullPath2)
  50.       if Err then
  51.         ws.RegWrite RegFullPath2, gaiwei2, "REG_DWORD"
  52.         Err.Clear
  53.       end if
  54.       if CStr(Value)=CStr(shuzhi2) then
  55.         ws.Popup RegFullPath2 & " 变成了 " & shuzhi2, nShowTime, strTitle, 4096
  56.         ws.RegWrite RegFullPath2, gaiwei2, "REG_DWORD"
  57.       end if
  58.   end if
  59. End Sub
复制代码
2

评分人数

    • zqz0012005: 乐于助人PB + 10 技术 + 1
    • wh1234567: 谢谢您给我满意的答案,很感激您,可惜我再 ...技术 + 1

TOP

完全搞定,谢谢powerbat

TOP

返回列表