变量值未在win批次中显示



我正在编写一批以自动安装许多设置,INI文件和apks在多种设备上。由于显示 null

的变量,我在批处理中遇到错误

我检查了 config.ini adbcommands.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

,因为您的路径有空间,您需要用引号包围路径。但是,当您这样做时,您需要告诉/f命令您仍在解析文件而不是变量。因此,您需要使用USUBACKQ选项。

@for /f "usebackq tokens=1,2 delims==" %%a in ("%config%") do (

@for /f "usebackq tokens=1,2 delims==" %%d in ("%Commands%") do (

相关内容

最新更新