In my batch script I have the following:
if somecondition (
exit
) else (
for /F "USEBACKQ tokens=4,6,8" %%a in (systeminfo ^| qgrep -e "System Up Time:") do set days=%%a&set hours=%%b&set minutes=%%c
set /A timepassed=%days%*24*60+%hours%*60+%minutes%
if "%timepassed%" leq 30 (
echo %timepassed%
) else (
echo %time$
)
)
有什么方法可以确保在将变量 timepassed 与值 30 进行比较之前设置它?有时,如果运行这部分代码,timepassed 似乎被评估为 "" 而不是它应该是什么。
谢谢你的时间