Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows Win批处理中未显示变量值_Windows_Batch File_Variables_Adb - Fatal编程技术网

Windows Win批处理中未显示变量值

Windows Win批处理中未显示变量值,windows,batch-file,variables,adb,Windows,Batch File,Variables,Adb,我正在编写一个批处理程序,以便在多种设备上自动安装许多设置、INI文件和APK。由于显示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 mul

我正在编写一个批处理程序,以便在多种设备上自动安装许多设置、INI文件和APK。由于显示NULL中的变量,批处理中出现错误

我已检查config.iniADBCommands.iniadb+.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
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
ini文件的内容 ADBCommands.ini

Build=XCover 3
Version=1.0.0
Creator=James B
DateModified=20/02/2017
ScreenTimeout=300000
UnknownSources=1
ScreenBrightness=225
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

因为路径有空格,所以需要用引号将路径括起来。但是当您这样做时,您需要告诉FOR/F命令您仍然在解析一个文件而不是一个变量。因此,您需要使用USEBACKQ选项

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


?您是否检查了文件权限?所有文件都具有完整的系统和用户权限您不需要将FOR meta variables设置为environment variables即可使用它们。只需直接使用元变量的。此外,您已经关闭了echo,因此不需要在所有命令前面加@。此外,我不理解您为什么使用:
cmd.exe/c
执行FOR命令。不管上述情况如何,这是大量需要排除故障的代码,我们都无法复制您的配置。您必须告诉我们您遇到问题的确切代码行。可能的重复代码工作得很好!非常感谢