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

[代码合集] 这个保护文件的批处理脚本有实用性吗

  1. @echo off&setlocal enabledelayedexpansion
  2. rem 保护的文件名
  3. set "input=C:\Program Files (x86)\kingsoft\kingsoft antivirus\kwtpanel.log"
  4. rem 保护间隔时间
  5. set ”#time=2“
  6. if "%1"=="h" goto begin
  7. start mshta vbscript:createobject("wscript.shell").run("""%~nx0"" h",0)(window.close)&&exit
  8. :begin
  9. if not exist %systemroot%\system32\certutil.exe call:msg_error_notfile&exit
  10. certutil -hashfile %input% MD5>%tmp%\MD5.LOG
  11. mshta VBScript:Msgbox("已在后台监控指定文件 [ %input% ]",vbSystemModal,"提示")(close)
  12. :main
  13. if not exist %input% call:msg_error_lostfile&exit
  14. set line=0
  15. for /f "delims=*" %%i in (%tmp%\MD5.LOG) do (
  16. set /a line+=1
  17. if !line!==2 set A=%%i
  18. )
  19. certutil -hashfile %input% MD5>%tmp%\MD5_.LOG
  20. set line=0
  21. for /f "delims=*" %%i in (%tmp%\MD5_.LOG) do (
  22. set /a line+=1
  23. if !line!==2 set B=%%i
  24. )
  25. if "%A%" neq "%B%" call:msg&exit
  26. ping 127.0.0.1 -n %#time% >nul
  27. goto:main
  28. :msg
  29. mshta VBScript:Msgbox("监控的文件 [ %input% ] 在 [ %date% %time% ] 被修改 文件原始指纹 [ %A% ] 修改后指纹 [ %B% ] 监控已终止。",vbSystemModal,"提示")(close)
  30. goto:eof
  31. :msg_error_lostfile
  32. mshta VBScript:Msgbox("监控的文件 [ %input% ] 在 [ %date% %time% ] 丢失 监控已终止。",vbSystemModal,"提示")(close)
  33. goto:eof
  34. :msg_error_notfile
  35. mshta VBScript:Msgbox("系统缺少需要的组件 [ certutil.exe ] 监控已终止。",vbSystemModal,"提示")(close)
  36. goto:eof
复制代码

只能检测文件修改 文件删除
没有certutil直接报错
不能还原文件

TOP

返回列表