-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuptime.bat
57 lines (47 loc) · 1.01 KB
/
uptime.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
@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
@pause
@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%""
@rem echo %_find_start_string%
@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=%%a
set _month=%%b
set _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 off
set _first= %_month:~0,1%
if %_first% == 0 (
set _month=%_month:~1,1%
)
@rem process _day
set _first= %_day:~0,1%
if %_first% == 0 (
set _day=%_day:~1,1%
)
@echo on
@GOTO :eof