[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
请打开一个cmd,按37楼的步骤把那些红色的命令逐条运行一次,确认一下是不是你的系统有问题。
确定没问题了就一切好说,不然大家永远无法沟通。

TOP

回复 47# wh1234567


你为什么不按我说的来呢?没有a.vbs和a.bat你建一个不就行了,内容已经type出来了。
现在重点是为什么我测试没问题而你一搞就报错,把这个原因找到其他功能随便加。

TOP

回复 49# wh1234567


    我怎么觉得你脑子还没转过弯来呢?

TOP

你说按37楼的步骤测试能行,那为什么还会出现第2个问题“弹出错误窗口”?出现错误了就说明不可行,你为什么要说测试可行呢?
不知道该说你可爱呢还是天真。。。

TOP

  1. Hive = "HKEY_LOCAL_MACHINE"
  2. KeyPath = "Software\333"
  3. ValueName = "444"
  4. On Error Resume Next
  5. Set ws = CreateObject("WScript.Shell")
  6. SINK_OnObjectReady 0, 0
  7. Set Sink = WScript.CreateObject("WbemScripting.SWbemSink", "SINK_")
  8. Set objWMIServices = GetObject("winmgmts:" & _
  9.     "{impersonationLevel=impersonate}!\\.\root\default")
  10. objWMIServices.ExecNotificationQueryAsync Sink, _
  11.     "Select * from RegistryValueChangeEvent Where " & _
  12.     "Hive = '"&Hive&"' and " & _
  13.     "KeyPath = '"&Replace(KeyPath,"\","\\")&"' and " & _
  14.     "ValueName = '"&ValueName&"'"
  15. WScript.Echo "Listening for Registry Change Events..." & vbCrLf
  16. Do : WScript.Sleep 1000 : Loop
  17. Sub SINK_OnObjectReady(wmiObject, wmiAsyncContext)
  18.     Value = ws.RegRead(Hive&"\"&KeyPath&"\"&ValueName)
  19.     'WScript.Echo Value
  20.     if CStr(Value)="29" then
  21.         ws.Popup "注册表值变成了29", 3, "通知"
  22.         ws.RegWrite Hive&"\"&KeyPath&"\"&ValueName, 20, "REG_DWORD"
  23.     end if
  24. End Sub
复制代码

TOP

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

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

返回列表