2016-07-27 9 views
-1

作業 されていない場合、私はnessesseryとバッチファイルプログラミング|声明は、私は私のコードに問題がある

コード が

をオフエコーいくつかの他のものの場合、.NETは、DirectXの9.0c以降のパッチをフレームワークのすべてをインストールします何かをプログラミングして
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 
) 

任意の改善がこれは環境変数がバッチファイル内のブロックの内部で展開されているかに関係している

+1

あなたはコードに関する問題について説明していません。 * if文が動作しない*は、有用な問題記述ではありません。どのようにして*働いていないのですか? –

+1

コードブロック内で変数(あなたの場合は '%arch%')を初期化して使用するには、[遅延拡張]が必要です(http://stackoverflow.com/questions/9681863/windows-batch -variables-wont-set)。 – SomethingDark

+0

'If定義されたProgramFiles(x86)(64ビットのエコー)Else(エコーオン32ビット)'は尋ねることなくあなたに伝えます。 –

答えて

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 
) 
+0

ありがとう!私はあなたから新しいことを学びました、もう一度あなたに感謝します – user5477777

関連する問題