I'm writing a simple batch script to get the last date/time of when a PC was rebooted. Found two simple ways:
systeminfo | find /i "Boot Time"which outputs:
System Boot Time: 5/4/2019, 5:04:44 AM
wmic os get lastbootuptimewhich outputs:
LastBootUpTime
20190504050444.500000-420
I'm basically looking to format the output of the second one to be the same or similar as the first one (something readable). On newer PCs, the first one works fine but most of our customers are still running Windows 7 and it takes forever for the first one to load while the second one is quite instant even on OS older than Windows 7.
I was thinking of putting the output of second one to a variable and doing regex stuff:
for /f %%i in ('wmic os get lastbootuptime') do set lastboottime=%%i
but I keep getting "%%i was unexpected at this time" error. I'm a PowerShell user and have no idea about batch syntax.