我有以下要求。
脚本:我的方法。
@echo off
REM Able to get the system up time.
for /F "tokens=1-2,3*" %%i IN ('net statistics workstation') do
if "Statistics since"=="%%i %%j" set DateTime=%%k %%l
Echo datetime=%DateTime%
REM Able to get the current system time.
set Curr=%date%%time%
echo Current=%Curr%
set Difference=%Curr%-%DateTime%
echo Difference
期望:
如果差异小于或等于60分钟,那么成功就会失败。
答案 0 :(得分:0)
以下是一些使用PowerShell的示例批处理代码。它旨在确定自上次启动以来的分钟数,根据60分钟的正常运行时间回显成功/失败消息。
@Echo Off
For /F "Delims=" %%A In ('PowerShell -C "[timespan]::FromMilliseconds("^
"[Math]::Abs([Environment]::TickCount)).TotalMinutes"'
) Do If %%~nA GEq 60 (Echo(Failure) Else Echo(Success
Timeout -1