在window xp下使用eventquery.vbs脚本输出当天电脑每次的启动时间

来源:互联网 发布:新加坡管理大学 知乎 编辑:程序博客网 时间:2024/05/21 17:14
@rem net statistics workstation | find /i  "statistics since"@echo off@CALL :set_date_var@rem CALL :print_year_month_day@CALL :format_month_day@rem CALL :print_year_month_day@CALL :set_date@CALL :find_start_string_from_event@GOTO :eof:find_start_string_from_event@set _find_start_string="cscript C:\WINDOWS\system32\eventquery.vbs /fi "id eq 6009" /l system | find "%_date%""@for /f "tokens=3,4 delims= " %%a in ('%_find_start_string%') do @echo %%a %%b@GOTO :eof:set_date_var@echo off@for /f "tokens=1,2,3 delims=- " %%a in ('date /t') do (set _year=%%aset _month=%%bset _day=%%c)@echo on@GOTO :eof:set_date@echo off@set _date=%_year%-%_month%-%_day%@echo on@GOTO :eof:print_year_month_day@echo off@echo  %_year% %_month% %_day%@echo on@GOTO :eof:format_month_day@echo offset _first= %_month:~0,1%if %_first% == 0 (set _month=%_month:~1,1%)@rem process _dayset _first= %_day:~0,1%if %_day% == 0 (set _month=%_day:~1,1%)@echo on@GOTO :eof

以上脚本用到了batch中的函数调用,将命令的结果保存到变量中,变量的使用等技巧。

因为date /t输出的时间格式和eventquery.vbs的输出不一样,所以转换了一下。


原创粉丝点击