I am trying to calculate the last time the computer was restarted with CMD.
But I don't want it in Year/month/day format.
Send the total number of days, hours and minutes
Here's what I've been able to do so far:
setlocal
for /f "skip=1" %%i in ('wmic /node:Computer /USER / os get lastbootuptime') do (
set string=%%i
goto next
)
:next
echo Son Restart: %string:~6,2%/%string:~4,2%/%string:~0,4%---%string:~8,2%:%string:~10,2%
Output: Son Restart: 17/11/2023---02:33
But what I need: 2 Days - 8 Hours - 43 Minutes
Note: I should only use CMD, no powershell
Thank you very much for your support in advance.
If you're happy to use WMIC, then might I offer an alternative method:
Of course you have the option of suffixing
- %s% Secondsto the output, should you require that too.