I`m trying to exectute a batch script only if server is restarted soon
the host machine is windows 2000 server and WMI is not working
so far i was able to gatther the uptime on the server with:
srvinfo -ns | findstr "Time:"
System Up Time: 0 Days, 7 Hr, 52 Min, 21 Sec
How build simple batch script wich says if uptime < 2 hours contiune if uptime > 2 hours go to end
Thank you alot in advance !!!
Not exactly rocket science . . .
for /F "tokens=4, 6" %%a in ('srvinfo -ns ^| find /i "Time:"') do (
if %%a GTR 0 goto :eof
if %%b GTR 2 goto :eof
but after 24 hours both statement for if are true
Your specification says "if uptime < 2 hours contiune if uptime > 2 hours go to end"
When the output from srvinfo.exe reads
System Up Time: 1 Days, 0 Hr, 52 Min, 21 Sec
then the system has been up for more than two hours and my batch file does exactly what you ask for. What's the problem?