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

批处理WMIC操作系统日志

如果不借助WMIC来处理系统日志,在不用第三方命令行工具的情况下还是有一定的难度。

  1. wmic nteventlog get filename
  2. rem 获取系统日志类型
  3. wmic nteventlog where filename="appevent" call cleareventlog
  4. rem 清除应用程序日志
  5. wmic nteventlog where filename="appevent" call BackupEventlog c:\\123.evt
  6. rem 将应用程序日志备份到c:\123.evt
  7. WMIC NTEVENT where "eventtype<648 and eventtype>624" GET Message,TimeGenerated
  8. rem 获取所有事件ID大于624但小于648的日志的描述,时间。即:帐户管理事件
  9. rem 下面显示了由“审核帐户管理”安全模板设置所生成的安全事件。
  10. rem   624:用户帐户已创建。
  11. rem   627:用户密码已更改。
  12. rem   628:用户密码已设置。
  13. rem   630:用户帐户已删除。
  14. rem   631:全局组已创建。
  15. rem   632:成员已添加至全局组。
  16. rem   633:成员已从全局组删除。
  17. rem   634:全局组已删除。
  18. rem   635:已新建本地组。
  19. rem   636:成员已添加至本地组。
  20. rem   637:成员已从本地组删除。
  21. rem   638:本地组已删除。
  22. rem   639:本地组帐户已更改。
  23. rem   641:全局组帐户已更改。
  24. rem   642:用户帐户已更改。
  25. rem   643:域策略已修改。
  26. rem   644:用户帐户被自动锁定。
  27. rem   645:计算机帐户已创建。
  28. rem   646:计算机帐户已更改。
  29. rem   647:计算机帐户已删除。
  30. rem   648:禁用安全的本地安全组已创建。
复制代码
WMIC不能创建系统事件,创建系统事件要用到eventcreate.exe ,这个应用程序的命令行帮助很详细就不贴上来了.

另外附上一个专门清除系统日志的脚本:
  1. @echo off
  2. setlocal enabledelayedexpansion
  3. if "%1" == "/?" goto :help
  4. set log_c=%1
  5. set log_c=!log_c:~1,4!
  6. if "%1" == "-all" (
  7. for /f "skip=1 tokens=*" %%a in ('wmic nteventlog get filename') do call :sub %%a
  8. ) else (
  9. for /f "usebackq skip=5 tokens=3 delims= " %%a in (
  10. `"wmic nteventlog where filename="!log_c!event" call cleareventlog"`
  11. ) do (
  12. if "%%a" == "0;" (
  13. echo 清除 !log_c!event 日志成功^^!
  14. ) else (
  15. echo 清除 !log_c!event 日志失败^^!
  16. )
  17. )
  18. )
  19. exit /b
  20. :sub
  21. for /f "usebackq skip=5 tokens=3 delims= " %%a in (
  22. `"wmic nteventlog where filename="%1" call cleareventlog"`
  23. ) do (
  24. if "%%a" == "0;" (
  25. echo 清除 %1 日志成功^^!
  26. ) else (
  27. echo 清除 %1 日志成功^^!
  28. )
  29. )
  30. goto :eof
  31. :help
  32. echo 系统日志清除脚本
  33. echo.
  34. echo BY:lxzzr http://bbs.bathome.net/
  35. echo.
  36. echo usage: clog.bat -all/app/sec/sys
  37. echo eg: clog.bat -sec
  38. exit /b
复制代码

[ 本帖最后由 lxzzr 于 2009-5-9 10:02 编辑 ]
1

评分人数

报错,何解?
Microsoft Windows XP [版本 5.1.2600]
(C) 版权所有 1985-2001 Microsoft Corp.

C:\Test>WMIC NTEVENT where "eventtype<648 and eventtype>624" GET Message,TimeGenerated
节点 - BATHOME-BATCHER
错误:
代码 = 0x80041017
说明 = 无效查询
设备 = WMI
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

回复 2楼 的帖子

你的系统里没有帐户管理事件!
将624 和648换成0和5试试?

TOP

我以前学习WMIC时做的笔记:
  1. rem 列举事件日志类型
  2. wmic Path Win32_NTEventlogFile get LogfileName /value|more
  3. rem 查询应用程序事件日志
  4. wmic Path Win32_NTLogEvent Where "Logfile='Application' and EventCode='1800'" get * /value|more
复制代码
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

回复 3楼 的帖子

C:\Test>WMIC NTEVENT where "eventtype<0 and eventtype>5" GET Message,TimeGenerated
无可用范例。
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

回复 5楼 的帖子

在我的机上是正常的,你的电脑上是不是没有事件ID大于0小于5的事件?

TOP

等于8的事件可以吗?
C:\Test>WMIC NTEVENT where "eventtype<0 and eventtype>10" GET Message,TimeGenerated
无可用范例。
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

回复 7楼 的帖子

0和10交换一下位置,呵呵,你那样的就是大于10而又要小于0的事件了,这样的事件有吗?

TOP

回复 8楼 的帖子

问题依旧
C:\Test>WMIC NTEVENT where "eventtype<10 and eventtype>0" GET Message,TimeGenerated
节点 - BATHOME-BATCHER
错误:
代码 = 0x80041001
说明 = 通用故障
设备 = WMI
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

将624改成0,648改成5,我的OK

TOP

我觉得这些命清日志也埋用的。

@echo off
wmic nteventlog get filename
rem 获取系统日志类型

wmic nteventlog where filename="AppEvent" call cleareventlog
rem 清除应用程序日志

wmic nteventlog where filename="SecEvent" call cleareventlog
rem 清除安全性日志

wmic nteventlog where filename="SysEvent" call cleareventlog
rem 清除系统日志

pause

TOP

回复 9楼 的帖子

汗!!
要不你就直接去掉条件:where "eventtype<10 and eventtype>0"
这样试试:WMIC NTEVENT GET Message,TimeGenerated

[ 本帖最后由 lxzzr 于 2009-5-11 03:21 编辑 ]

TOP

11楼的方法好像行得通。谢谢!

TOP

返回列表