设置语句语法不正确?

时间:2015-01-27 06:46:31

标签: batch-file syntax set

我似乎无法弄清楚这里出了什么问题:

file2existfile3exist等不会从“false”更改为“true”。

文件列表,readme.txt和Install-Uninstall.bat中的if语句都不会激活。

Here is a download link to the batch file.

@echo OFF
SETLOCAL ENABLEDELAYEDEXPANSION

:intro
echo Welcome to The W:RD Noob's WARGAME MOD PACKAGER.
echo.
echo This program automatically creates a download package for a simple W:RD Mod.
echo It can support up to 5 different files.
echo Please remember that this program is case-sensitive.
echo.
echo Press any key to continue to the next step.
pause >nul

:info
cls
echo MOD DETAILS INFO
echo.
echo Please fill out the following information about your mod.
echo What is the name of the mod? (i.e. Sandbox)
set /P "ModName="
echo Who is the mod made by? (i.e. The W:RD Noob)
set /P "Author="
echo What version is the mod currently on? (i.e. 1.0)
set /P "Version="
echo.

:confirm1
echo Is this correct? (Answer "Yes" or "No")
echo It should look like this: Sandbox Mod version 1.0 by The W:RD Noob
echo %ModName% Mod version %Version% by %Author%
set /P "ConfirmAnswerA="
if "%ConfirmAnswerA%"=="Yes" (goto filestart) else if %ConfirmAnswerA%==No (goto info) else (goto confirm1)

:filestart
if "%finalredirectmode%"=="true" (goto finalcheck) else (goto filestartcontinue)

:filestartcontinue
set redirectmode=false
set file2exist=false
set file3exist=false
set file4exist=false
set file5exist=false
set ab=false
set ac=false
set ad=false
set ae=false
set bc=false
set bd=false
set be=false
set cd=false
set ce=false
set de=false

:file1
cls
echo MOD FILE 1 DETAILS
echo.
echo Type the name of one file that your mod uses (i.e. NDF_Win.dat).
set /P "File1="
echo Type the location of that file (i.e. Data\WARGAME\PC\430000210).
echo Remember to use backslashes.
set /P "Location1="
echo.

:askfile1
echo Is this correct? (Answer "Yes" or "No")
echo %Location1%\%File1%
set /P "ConfirmFile1="
if "%ConfirmFile1%"=="Yes" (goto file2) else if %ConfirmFile1%==No (goto file1) else (goto askfile1)

:file2
if "%redirectmode%"=="true" (goto allfilecheck) else (goto file2next)

:file2next
cls
echo MOD FILE 2 DETAILS
echo.
echo Type the name of a second file that your mod uses (i.e. NDF_Win.dat)
echo If you have no other file, type "Pass".
set File2Name=Null
set /P "File2="
if "%File2%" == "%File1%" (set ab=true) else (set ab=false)
if "%File2%" == "Pass" (goto allfilecheck) else (goto continue2)
::if %File2%==Pass goto check else goto continue2

:continue2
echo Type the location of that file starting with Data\.
echo Remember to use backslashes.
set /P "Location2="
echo.

:askfile2
echo Is this correct? (Answer "Yes" or "No")
echo %Location2%\%File2%
set /P "ConfirmFile2="
if %ConfirmFile2%==Yes (goto file3) else if %ConfirmFile2%==No (goto file2) else (goto askfile2)

:file3
set file2exist==true
if "%redirectmode%"==true (goto allfilecheck) else (goto file3next)

:file3next
cls
echo MOD FILE 3 DETAILS
echo.
echo Type the name of a third file that your mod uses (i.e. NDF_Win.dat)
echo If you have no other file, type "Pass".
set /P "File3="
if "%File3%" == "Pass" (goto allfilecheck) else (goto continue3)
if "%File3%" == "%File1%" (set ac=true) else (set ac=false)
if "%File3%" == "%File2%" (set bc=true) else (set bc=false)

:continue3
echo Type the location of that file starting with Data\.
echo Remember to use backslashes.
set /P "Location3="
echo.

:askfile3
echo Is this correct? (Answer "Yes" or "No")
echo %Location1%\%File3%
set /P "ConfirmFile3="
if "%ConfirmFile3%"=="Yes" (goto file4) else if "%ConfirmFile3%"=="No" (goto file3) else (goto askfile3)

:file4
set file3exist==true
if "%redirectmode%"=="true" (goto allfilecheck) else (goto file4next)

:file4next
cls
echo MOD FILE 4 DETAILS
echo.
echo Type the name of a fourth file that your mod uses (i.e. NDF_Win.dat)
echo If you have no other file, type "Pass".
set /P "File4="
if "%File4%" == "Pass" (goto allfilecheck) else (goto continue4)
if "%File4%" == "%File1%" (set ad=true) else (set ad=false)
if "%File4%" == "%File2%" (set bd=true) else (set bd=false)
if "%File4%" == "%File3%" (set cd=true) else (set cd=false)

:continue4
echo Type the location of that file starting with Data\.
echo Remember to use backslashes.
set /P "Location4="
echo.

:askfile4
echo Is this correct? (Answer "Yes" or "No")
echo %Location1%\%File4%
set /P "ConfirmFile4="
if %ConfirmFile4%==Yes (goto file5) else if %ConfirmFile4%==No (goto file4) else (goto askfile4)

:file5
set file4exist==true
if "%redirectmode%"=="true" (goto allfilecheck) else (goto file5next)

:file5next
cls
echo MOD FILE 5 DETAILS
echo.
echo Type the name of fifth file that your mod uses (i.e. NDF_Win.dat)
echo If you have no other file, type "Pass".
set /P "File5="
if "%File5%" == "Pass" (goto allfilecheck) else (goto continue5)
if "%File5%" == "%File1%" (set ae=true) else (set ae=false)
if "%File5%" == "%File2%" (set be=true) else (set be=false)
if "%File5%" == "%File3%" (set ce=true) else (set ce=false)
if "%File5%" == "%File4%" (set de=true) else (set de=false)

:continue5
echo Type the location of that file starting with Data\.
echo Remember to use backslashes.
set /P "Location5="
echo.

:askfile5
echo Is this correct? (Answer "Yes" or "No")
echo %Location5%\%File5%
set /P "ConfirmFile5="
if "%ConfirmFile5%"=="Yes" (goto lastfile) else if "%ConfirmFile5%"=="No" (goto file5) else (goto askfile5)

:lastfile
set file5exist==true
goto allfilecheck

:allfilecheck
cls
echo FILE LIST
echo.
::if "%ab%" == "false" (echo "ab false") else (echo "ab true")
echo File 1 = Wargame Red Dragon\%Location1%\%File1%
if %file2exist%=="true" (goto typefile2) else (goto nofile2)
:typefile2
echo File 2 = Wargame Red Dragon\%Location2%\%File2%
goto file3mightexist
:nofile2
goto filelastconfirm
:file3mightexist
if %file3exist%=="true" (goto typefile3) else (goto nofile3)
:typefile3
echo File 3 = Wargame Red Dragon\%Location3%\%File3%
goto file4mightexist
:nofile3
goto filelastconfirm
:file4mightexist
if %file4exist%=="true" (goto typefile4) else (goto nofile4)
:typefile4
echo File 4 = Wargame Red Dragon\%Location4%\%File4%
goto file5mightexist
:nofile4
goto filelastconfirm
:file5mightexist
if %file5exist%=="true" (goto typefile5) else (goto nofile5)
:typefile5
echo File 5 = Wargame Red Dragon\%Location5%\%File5%
goto filelastconfirm
:nofile5
goto filelastconfirm

:filelastconfirm
echo Is this correct? (Answer "Yes" or "No")
set /P "FileLastConfirmQ="
if "%FileLastConfirmQ%"=="Yes" (goto finalcheck) else if "%FileLastConfirmQ%"=="No" (goto fileredirect) else (goto filelastconfirm)

:fileredirect
set redirectmode=true
echo Which file has incorrect information?
echo.
echo Type 1 for File 1, 2 for File 2, etc.
echo To add another file, type the next file number. (It can only go up to 5)
set /P "FileRedirectQ="
if "%FileRedirectQ%"=="1" (goto file1) else if "%FileRedirectQ%"=="2" (goto file2next) else if "%FileRedirectQ%"=="3" (goto file3next) else if "%FileRedirectQ%"=="4" (goto file4next) else if "%FileRedirectQ%"=="5" (goto file5next) else (goto fileredirect)
pause

:finalcheck
cls
set finalredirectmode=true
echo FINAL MOD CHECK
echo Is all this information correct?
echo.
echo ---------------------------------------------------------------------------
echo.
echo Name of Mod: %ModName%
echo Mod Version: %Version%
echo Author: %Author%
echo.
echo Files:
echo File 1 = Wargame Red Dragon\%Location1%\%File1%
if "%file2exist%" == "true" (goto typefile2) else (goto nofile2)
:typefile2
echo File 2 = Wargame Red Dragon\%Location2%\%File2%
goto file3mightexist
:nofile2
goto lastcheckq
:file3mightexist
if "%file3exist%" == "true" (goto typefile3) else (goto nofile3)
:typefile3
echo File 3 = Wargame Red Dragon\%Location3%\%File3%
goto file4mightexist
:nofile3
goto lastcheckq
:file4mightexist
if "%file4exist%" == "true" (goto typefile4) else (goto nofile4)
:typefile4
echo File 4 = Wargame Red Dragon\%Location4%\%File4%
goto file5mightexist
:nofile4
goto lastcheckq
:file5mightexist
if "%file5exist%" == "true" (goto typefile5) else (goto nofile5)
:typefile5
echo File 5 = Wargame Red Dragon\%Location5%\%File5%
goto lastcheckq
:nofile5
goto lastcheckq

:lastcheckq
echo Is all of this information correct? (Answer "Yes" or "No")
echo This is your last chance to make a change.
set /P "FinalConfirmQ="
if "%FinalConfirmQ%"=="Yes" (goto startprocess) else if "%FinalConfirmQ%"=="No" (goto wherenow) else (goto lastcheckq)

:wherenow
echo Do you want to change mod details or files?
echo Type "Details" or "Files".
set /P "Wherenowq="
if "%Wherenowq%"=="Details" (goto info) else if "%Wherenowq%"=="Files" (goto allfilecheck) else (goto wherenow)


:startprocess
cls
echo PROGRESS REPORT
echo.
echo Creating Organization...
md "0_%ModName%_Mod(%Version%)\"
md "0_%ModName%_Mod(%Version%)\File1\"
echo.>"0_%ModName%_Mod(%Version%)\File1\Place_File_1_Here.txt"
if "file2exist"=="true" (goto file2store) else (goto startbatting)
:file2store
md "0_%ModName%_Mod(%Version%)\File2\"
echo.>"0_%ModName%_Mod(%Version%)\File2\Place_File_2_Here.txt"
echo 2nd file sucsessful
if "file3exist"=="true" (goto file3store) else (goto startbatting)
:file3store
md "0_%ModName%_Mod(%Version%)\File3\"
echo.>"0_%ModName%_Mod(%Version%)\File3\Place_File_3_Here.txt"
if "file4exist"=="true" (goto file4store) else (goto startbatting)
:file4store
md "0_%ModName%_Mod(%Version%)\File4\"
if "file5exist"=="true" (goto file5store) else (goto startbatting)
echo.>"0_%ModName%_Mod(%Version%)\File4\Place_File_4_Here.txt"
:file5store
md "0_%ModName%_Mod(%Version%)\File5\"
echo.>"0_%ModName%_Mod(%Version%)\File5\Place_File_5_Here.txt"
::Location1

:startbatting
echo Writing Batch File...
echo.>"Install-Uninstall.bat"

::INSTALL.BAT STARTS NOW
@echo @echo OFF> Install-Uninstall.bat
@echo SETLOCAL ENABLEDELAYEDEXPANSION>> Install-Uninstall.bat
@echo color 0a>> Install-Uninstall.bat

@echo :question>> Install-Uninstall.bat
@echo echo Do you want to install or uninstall the %ModName% mod? (Answer "1" for Install or "2" for Uninstall)>> Install-Uninstall.bat
@echo set /P "Choice=">> Install-Uninstall.bat
@echo if "%%Choice%%"=="1" (goto inst) else if "%%Choice%%"=="2" (goto uninst) else (goto question)>> Install-Uninstall.bat

@echo :inst>> Install-Uninstall.bat
@echo if exist 0%ModName%Installed.txt (goto already) else (goto install)>> Install-Uninstall.bat

@echo :already>> Install-Uninstall.bat
@echo echo %ModName% %Version% is already installed.>> Install-Uninstall.bat
@echo echo Press any key to close the window.>> Install-Uninstall.bat
@echo pause ^>nul>> Install-Uninstall.bat
@echo exit>> Install-Uninstall.bat

@echo :install>> Install-Uninstall.bat
@echo echo INSTALLING %ModName%>> Install-Uninstall.bat
@echo echo (W:RD Modification)>> Install-Uninstall.bat
@echo echo Mod made by %Author%>> Install-Uninstall.bat
@echo echo -------------------------------------->> Install-Uninstall.bat
@echo echo Mod Installing...>> Install-Uninstall.bat
@echo ren ..\%Location1%\%File1% ORIGINAL-%File1%>> Install-Uninstall.bat
@echo copy /-y "%%cd%%\%File1%" "%%cd%%\..\%Location1%\">> Install-Uninstall.bat
@echo echo File 1 (%File1%) Replaced.>> Install-Uninstall.bat

if "file2exist"=="true" (goto file2bat) else (goto endbat)
:file2bat
@echo ren ..\%Location2%\%File2% ORIGINAL-%File2%>> Install-Uninstall.bat
@echo copy /-y "%%cd%%\%File2%" "%%cd%%\..\%Location2%\">> Install-Uninstall.bat
@echo echo File 2 (%File2%) Replaced.>> Install-Uninstall.bat

if "file3exist"=="true" (goto file3bat) else (goto endbat)
:file3bat
@echo ren ..\%Location3%\%File3% ORIGINAL-%File3%>> Install-Uninstall.bat
@echo copy /-y "%%cd%%\%File3%" "%%cd%%\..\%Location3%\">> Install-Uninstall.bat
@echo echo File 3 (%File3%) Replaced.>> Install-Uninstall.bat

if "file4exist"=="true" (goto file4bat) else (goto endbat)
:file4bat
@echo ren ..\%Location4%\%File4% ORIGINAL-%File4%>> Install-Uninstall.bat
@echo copy /-y "%%cd%%\%File4%" "%%cd%%\..\%Location4%\">> Install-Uninstall.bat
@echo echo File 4 (%File4%) Replaced.>> Install-Uninstall.bat

if "file5exist"=="true" (goto file5bat) else (goto endbat)
:file5bat
@echo ren ..\%Location5%\%File5% ORIGINAL-%File5%>> Install-Uninstall.bat
@echo copy /-y "%%cd%%\%File5%" "%%cd%%\..\%Location5%\">> Install-Uninstall.bat
@echo echo File 5 (%File5%) Replaced.>> Install-Uninstall.bat

:endbat
@echo if exist ..\ZZListOfMods.txt (goto done) else (goto firsttime)
@echo :firsttime >> Install-Uninstall.bat
@echo echo.^>^>"..\ZZListOfMods.txt" >> Install-Uninstall.bat

@echo :done >> Install-Uninstall.bat
@echo @echo %ModName% was installed at %%time%%, %%date%%^>^>..\ZZListOfMods.txt >> Install-Uninstall.bat
@echo echo Installation Finished. >> Install-Uninstall.bat
@echo echo Press any key to close the window. >> Install-Uninstall.bat
@echo pause ^>nul>> Install-Uninstall.bat
@echo exit>> Install-Uninstall.bat

@echo :uninst>> Install-Uninstall.bat
@echo if exist 0%ModName%(%Version%)NotInstalled.txt (goto already) else (goto uninstall)>> Install-Uninstall.bat

@echo :already>> Install-Uninstall.bat
@echo echo %ModName% %Version% is already uninstalled.>> Install-Uninstall.bat
@echo echo Press any key to close the window.>> Install-Uninstall.bat
@echo pause ^>nul>> Install-Uninstall.bat
@echo exit>> Install-Uninstall.bat

@echo :uninstall>> Install-Uninstall.bat
@echo echo UNINSTALLING %ModName%>> Install-Uninstall.bat
@echo echo (W:RD Modification)>> Install-Uninstall.bat
@echo echo Mod Uninstalling...>> Install-Uninstall.bat
@echo del "..\%Location1%\%File1%">> Install-Uninstall.bat
@echo ren ..\%Location1%\ORIGINAL-%File1% %File1%>> Install-Uninstall.bat

if "file2exist"=="true" (goto uninstfile2bat) else (goto uninstendbat)
:uninstfile2bat
@echo del "..\%Location2%\%File2%">> Install-Uninstall.bat
@echo ren ..\%Location2%\ORIGINAL-%File2% %File2%>> Install-Uninstall.bat

if "file3exist"=="true" (goto uninstfile3bat) else (goto uninstendbat)
:uninstfile3bat
@echo del "..\%Location3%\%File3%">> Install-Uninstall.bat
@echo ren ..\%Location3%\ORIGINAL-%File3% %File3%>> Install-Uninstall.bat

if "file4exist"=="true" (goto uninstfile4bat) else (goto uninstendbat)
:uninstfile4bat
@echo del "..\%Location4%\%File4%">> Install-Uninstall.bat
@echo ren ..\%Location4%\ORIGINAL-%File4% %File4%>> Install-Uninstall.bat

if "file5exist"=="true" (goto uninstfile5bat) else (goto uninstendbat)
:uninstfile5bat
@echo del "..\%Location5%\%File5%">> Install-Uninstall.bat
@echo ren ..\%Location5%\ORIGINAL-%File5% %File5%>> Install-Uninstall.bat

:uninstendbat
@echo @echo %ModName% was uninstalled at %time%, %date%>>..\ZZListOfMods.txt
@echo ren 0%ModName%(%Version%)Installed.txt 0%ModName%(%Version%).txt>> Install-Uninstall.bat
@echo echo Uninstallation Finished.>> Install-Uninstall.bat
@echo Press any key to close the window.>> Install-Uninstall.bat
@echo pause ^>nul>> Install-Uninstall.bat
@echo exit>> Install-Uninstall.bat

:readme
echo Writing readme.txt...
echo.>"readme.txt"
@echo %Author% presents: > readme.txt
@echo A Wargame: Red Dragon mod>> readme.txt
@echo. >> readme.txt
@echo %ModName% %Verion% >> readme.txt
@echo ---------------------------------------------------------------------------------->> readme.txt
@echo. >> readme.txt
@echo CONTENTS LIST: >> readme.txt
@echo Install-Uninstall.bat >> readme.txt
@echo %File1% >> readme.txt
if "file2exist"=="true" (goto listfile2) else (goto endlist)
:listfile2
@echo %File2% >> readme.txt
if "file3exist"=="true" (goto listfile3) else (goto endlist)
:listfile3
@echo %File3% >> readme.txt
if "file4exist"=="true" (goto listfile4) else (goto endlist)
:listfile4
@echo %File4% >> readme.txt
if "file5exist"=="true" (goto listfile5) else (goto endlist)
:listfile5
@echo %File5% >> readme.txt
:endlist
@echo readme.txt >> readme.txt
@echo 0%ModName%Installed.txt >> readme.txt
@echo ---------------------------------------------------------------------------------->> readme.txt
@echo. >> readme.txt
@echo INSTALL INSTRUCTIONS >> readme.txt
@echo 1. Extract the folder %cd%\0_%ModName%_Mod(%Version%) to your Wargame Red Dragon folder. >> readme.txt
@echo (The default location for PC is "C:\Program Files (x86)\Steam\SteamApps\common\Wargame Red Dragon".) >> readme.txt
@echo 2. Go inside the folder and double-click on "Install-Uninstall.bat" >> readme.txt
@echo 3. Notice the .txt file below has been changed to "0CCInstalled" This is your indication that the mod is installed. NEVER DELETE THIS TEXT FILE. >> readme.txt
@echo 4. Play Wargame: Red Dragon normally. There is nothing to do for the mod to activate. >> readme.txt
@echo ---------------------------------------------------------------------------------->> readme.txt
@echo. >> readme.txt
@echo Uninstall Instructions: >> readme.txt
@echo 1. Double-click on "Install-Uninstall.bat" >> readme.txt
@echo ---------------------------------------------------------------------------------->> readme.txt
@echo. >> readme.txt
@echo Credits: >> readme.txt
@echo Mod by %Author% >> readme.txt
@echo WargameModdingSuite by Enohka >> readme.txt
@echo WargameModPackager by The W:RD Noob >> readme.txt
@echo ---------------------------------------------------------------------------------->> readme.txt
@echo. >> readme.txt
@echo CHANGELOG:>> readme.txt
@echo. >> readme.txt
@echo. >> readme.txt
@echo ---------------------------------------------------------------------------------->> readme.txt
@echo. >> readme.txt
@echo AUTHOR'S NOTES: >> readme.txt
@echo. >> readme.txt
@echo. >> readme.txt
@echo ---------------------------------------------------------------------------------->> readme.txt


:receipt
@echo Writing receipt...
@echo.>"receipt.txt"
@echo %ModName% Receipt > receipt.txt
@echo Name of Mod: %ModName% >> receipt.txt
@echo Version of Mod: %Version% >> receipt.txt
@echo Author of Mod: %Author% >> receipt.txt
@echo File 1: Wargame Red Dragon\%Location1%\%File1% >> receipt.txt
if "file2exist"=="true" (goto refile2) else (goto endre)
:refile2
@echo File 2: Wargame Red Dragon\%Location2%\%File2% >> receipt.txt
if "file3exist"=="true" (goto refile3) else (goto endre)
:refile3
@echo File 3: Wargame Red Dragon\%Location3%\%File3% >> receipt.txt
@echo  >> receipt.txt
if "file4exist"=="true" (goto refile4) else (goto endre)
:refile4
@echo File 4: Wargame Red Dragon\%Location4%\%File4% >> receipt.txt
if "file5exist"=="true" (goto refile5) else (goto endre)
:refile5
@echo File 5: Wargame Red Dragon\%Location5%\%File5% >> receipt.txt
:endre
@echo Install-Uninstall.bat, readme.txt, receipt.txt completed >> receipt.txt
@echo All packaging processes finished at %time%, %date% >> receipt.txt
@echo. >> receipt.txt
@echo. >> receipt.txt
@echo Wargame Mod Packager Made by The W:AB Noob >> receipt.txt
@echo January, 2015 >> receipt.txt
@echo If you have any questions, please email at wargamelearningprogramemail@gmail.com >> receipt.txt


echo PROGRAM FINISHED
echo.
echo Be sure to edit the readme.txt for yourself
echo If you have any questions, please email The W:RD Noob at wargamelearningprogramemail@gmail.com
echo.
echo Press any key to close the program.
pause >nul
exit


::Installer made by The W:AB Noob

1 个答案:

答案 0 :(得分:0)

是的,非常简单

第99行:

set file2exist==true

应该是:

set file2exist=true

就我所见,很多行存在此问题。但是通过 529 线搜索不是我的一杯茶,所以我不会列出这个问题的多次出现。

这两个=用于if语句,简单来说就是这样。

相关问题