0
我正在編寫批處理以自動安裝多個設備上的多個設置,INI文件和APK。由於顯示NULL中的變量,因此批次中出現錯誤。Win Batch中未顯示變量值
我已經檢查了的config.ini和ADBCommands.ini和亞行+蝙蝠是在正確的位置。
你能幫忙嗎?
::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
¿你檢查文件的權限? – AFR
所有文件都具有完整的系統和用戶權限 – beecho01
您不需要將FOR元變量設置爲環境變量即可使用它們。只需直接使用FOR元變量。另外,你已經有回聲了,所以你不需要在@所有的命令之前。另外,我不明白你爲什麼使用:'cmd.exe/c'來執行你的FOR命令。 – Squashman