Code: Select all
@echo off
:: time zone is not used to deal better with - and + signs
for /f %%$ in ('wmic os get LastBootUpTime /format:value') do (
for /f %%# in ("%%$") do set "%%#"
)
set offset=%LastBootUpTime:~21,4%
::get current time
for /f %%$ in ('wmic os get LocalDateTime /format:value') do (
for /f %%# in ("%%$") do set "%%#"
)
set "today=%LocalDateTime:~0,8%"
set "endOfTheDay=%today%235959.999999%offset%"
set "startOfTheDay=%today%000000.000000%offset%"
set "_path=%_path:\=\\%\\"
rem and LastModified<='%edate%' and LastModified>='%bdate%'
for /f "skip=1 tokens=* delims=" %%# in ('
wmic os where "LastBootUpTime<='%endOfTheDay%' and LastBootUpTime>='%startOfTheDay%' " get LastBootUpTime /Format:table
') do (
for /f "tokens=* delims=" %%A in ("%%#") do (
if "%%A" neq "" echo booted today
)
)
date time is a primitive type in MOF/CIM/WMI
Code: Select all
https://msdn.microsoft.com/en-us/library/aa387237(v=vs.85).aspx
https://msdn.microsoft.com/en-us/library/aa389802(v=vs.85).aspx
And is used in a lot of WMI objects (file times , os times ...)
I don't know if is possible to be used in WQL queries and within clause (with intervals):
Code: Select all
https://msdn.microsoft.com/en-us/library/aa394527(v=vs.85).aspx
https://msdn.microsoft.com/en-us/library/aa390895(v=vs.85).aspx