我正在编写一个批处理,以便在多个设备上自动安装许多设置、INI文件和APK。由于显示空的变量,我在批处理中出现了错误。
我已经检查了config.ini和adb+.bat在正确的位置。
你能帮上忙吗?
::Global
@echo off
cd C:\
::INI Locations
set mypath=%~dp0
set config=%mypath%config.ini
set Commands=%mypath%ADBCommands.ini
set multi=%mypath%adb+.bat
@pause
::Set Varialbes
@for /f "tokens=1,2 delims==" %%a in (%config%) do (
if %%a==Build set Build=%%b
if %%a==Version set Version=%%b
if %%a==Creator set Creator=%%b
if %%a==DateModified set DateModified=%%b
if %%a==ScreenTimeout set ScreenTimeout=%%b
if %%a==UnknownSources set UnknownSources=%%b
if %%a==ScreenBrightness set ScreenBrightness=%%b
)
@for /f "tokens=1,2 delims==" %%d in (%Commands%) do (
if %%d==ScreenTimeoutCommand set ScreenTimeoutCommand=%%e
if %%d==UnknownSourcesCommand set UnknownSourcesCommand=%%e
if %%d==ScreenBrightnessCommand set ScreenBrightnessCommand=%%e
if %%d==OpenSOTICommand set OpenSOTICommand=%%e
)
::Build information
cls
@echo.
@echo.
@echo BUILD: %Build%
@echo VERSION: %Version%
@echo BUILD CREATOR: %Creator%
@echo LAST UPDATED: %DateModified%
@echo.
@echo.
@pause目录ini文件config.ini
Build=XCover 3
Version=1.0.0
Creator=James B
DateModified=20/02/2017
ScreenTimeout=300000
UnknownSources=1
ScreenBrightness=225包含ini文件ADBCommands.ini
ScreenTimeoutCommand=shell settings put system screen_off_timeout
UnknownSourcesCommand=shell settings put system install_non_market_apps
OpenSOTICommand=shell am start -n net.soti.mobicontrol.elm.samsung/net.soti.mobicontrol.startup.SplashActivity发布于 2017-02-20 17:15:16
因为路径有空格,所以需要用引号将路径括起来。但是当您这样做时,您需要告诉FOR /F命令,您仍然在解析一个文件,而不是一个变量。所以你需要使用USEBACKQ选项。
@for /f "usebackq tokens=1,2 delims==" %%a in ("%config%") do (和
@for /f "usebackq tokens=1,2 delims==" %%d in ("%Commands%") do (https://stackoverflow.com/questions/42349236
复制相似问题