Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- :: Set the window size
- mode con: cols=55 lines=10
- :loop
- cls
- echo Saved uptime stats
- echo.
- :: Get the current date, time, and uptime and save it to the file
- echo %date% %time% >> uptime.txt
- net statistics workstation | find "Statistics since" >> uptime.txt
- echo. >> uptime.txt
- :: Extract the start date and time of uptime
- for /f "tokens=3-8" %%a in ('net statistics workstation ^| find "Statistics since"') do (
- set start_date=%%a
- set start_time=%%b %%c %%d
- )
- :: Calculate the elapsed time in minutes
- for /f "tokens=1-4 delims=/: " %%a in ("%start_date% %start_time%") do (
- set /a start_year=%%a, start_month=%%b, start_day=%%c
- set /a start_hour=%%d, start_minute=%%e
- )
- :: Get current date and time
- set /a current_year=%date:~6,4%
- set /a current_month=%date:~0,2%
- set /a current_day=%date:~3,2%
- set /a current_hour=%time:~0,2%
- set /a current_minute=%time:~3,2%
- :: Calculate elapsed hours and minutes (approximated)
- set /a elapsed_minutes=(current_hour*60 + current_minute) - (start_hour*60 + start_minute)
- set /a elapsed_hours=elapsed_minutes / 60
- set /a elapsed_minutes=elapsed_minutes %% 60
- :: Display the calculated uptime
- echo Current Uptime: %start_date% %start_time%
- echo Uptime (calculated): %elapsed_hours% hours and %elapsed_minutes% minutes
- :: Wait for 5 minutes (300 seconds)
- timeout /t 300 /nobreak > nul
- goto loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement