我的代码有问题, 我编写的东西会安装所有.net框架的directx 9.0c补丁,如果nessessery和其他一些东西
代码 回声
echo \====================================/
echo / A repackage of all essential files \
echo \ that are required to be installed /
echo / so installing them manually isn't \
echo \ a big problem. /
echo /====================================\
echo \ Continue at your own risk!!! /
echo /====================================\
echo.
echo Type yes to continue or no to cancel:
set /p Reponse=""
cls
if %Reponse% == yes (
echo what's is your CPU architecture? 32-Bit or 64-Bit?
echo to help, look at your ram, if it's below the 4GB Then its 32-bit
set /p arch=""
if %arch% == 32-bit (
cls
echo starting Installation
)
echo starting installation process
)
if %Reponse% == no (
echo Shutting Down
echo Thank you for your participation
)
pause
破碎的部分:
if %Reponse% == yes (
echo what's is your CPU architecture? 32-Bit or 64-Bit?
echo to help, look at your ram, if it's below the 4GB Then its 32-bit
set /p arch=""
if %arch% == 32-bit (
cls
echo starting Installation
)
echo starting installation process
)
当代码的这部分不存在时,它正在工作:
echo what's is your CPU architecture? 32-Bit or 64-Bit?
echo to help, look at your ram, if it's below the 4GB Then its 32-bit
set /p arch=""
if %arch% == 32-bit (
cls
echo starting Installation
)
任何改进都将受到赞赏
感谢您阅读
抱歉我的英语不好
答案 0 :(得分:0)
这与如何在批处理文件中的块内扩展环境变量有关。要覆盖此行为,请使用setlocal enabledelayedexpansion
并使用!
代替%
来引用环境变量。
@echo off
setlocal enabledelayedexpansion
... existing code here ...
if %Reponse% == yes (
echo what's is your CPU architecture? 32-Bit or 64-Bit?
echo to help, look at your ram, if it's below the 4GB Then its 32-bit
set /p arch=""
if !arch! == 32-bit (
cls
echo starting Installation
)
echo starting installation process
)