下面是我一直在处理的批处理脚本,但是,我无法超越定位脚本解析的配置文件。当我运行脚本时,我收到一条错误消息:系统找不到该文件
D:\WKGPDATA\INFOtrac\Conduit\Conduit.ini
@echo off
REM Disable command echo for cleaner output.
REM Function to compare LastScanUTC time stamp with current UTC time.
:CompareTime
setlocal
REM Get the LastScanUTC time stamp from the configuration file.
for /f "usebackq tokens=2 delims==" %%a in ("D:\WKGPDATA\INFOtrac\Conduit\Conduit.ini") do (
set LastScanUTC=%%a
)
REM snipped all unrelated lines here
endlocal
goto :EOF
它应该从位于
"D:\WKGPDATA\INFOtrac\Conduit"
的配置文件中读取LastScanUTC时间戳,并将其分配给变量LastScanUTC
。
您可以在脚本中添加检查,以在尝试读取文件之前验证文件是否存在。
@echo off
REM Disable command echo for cleaner output.
REM Path to the configuration file
set "ConfigPath=D:\WKGPDATA\INFOtrac\Conduit\Conduit.ini"
REM Check if the configuration file exists
if not exist "%ConfigPath%" (
echo Configuration file not found at %ConfigPath%.
exit /b
)
REM Function to compare LastScanUTC time stamp with current UTC time.
:CompareTime
setlocal
REM Get the LastScanUTC time stamp from the configuration file.
for /f "usebackq tokens=2 delims==" %%a in ("%ConfigPath%") do (
set LastScanUTC=%%a
)
REM snipped all unrelated lines here
endlocal
goto :EOF