正确的批处理 if-goto 语句?
Proper Batch if-goto statement?
我终于解决了我的问题。现在我确实有 %verion%
和 %ModName%
的正确参数,它在批处理文件中更早地工作。此外,此 if 语句的确切格式之前已在同一个批处理文件中成功使用(我不确定之后)。通过放置 if "file2exist"=="true" echo true
的语句,我也知道它确实具有 "true"
的值这一事实。现在我将上一句的代码放在第 4 行和第 5 行之间,计算机进行了回显。这意味着第 4 行以某种方式被忽略了? (1-3行和10-11行有效,6-8行好像完全跳过了)
出了什么问题?
我先谢谢你了。非常感谢任何建议。
mkdir "0_%ModName%_Mod(%Version%)\"
mkdir "0_%ModName%_Mod(%Version%)\File1\"
echo.>"0_%ModName%_Mod(%Version%)\File1\Place_File_1_Here.txt"
if "file2exist"=="true" goto filetwostore
goto startbatting
:filetwostore
mkdir 0_%ModName%_Mod(%Version%)\File2\
echo.>"0_%ModName%_Mod(%Version%)\File2\Place_File_2_Here.txt"
:startbatting
echo Writing Batch File...
echo.>"Install-Uninstall.bat"
if "file2exist"=="true" goto filetwostore
等同于
if 1==2 goto filetwostore
如果两个不同的字符串不同,则它们不能相等
也许,你需要
if "%file2exist%"=="true" goto filetwostore
比较变量值,而不是变量名
我终于解决了我的问题。现在我确实有 %verion%
和 %ModName%
的正确参数,它在批处理文件中更早地工作。此外,此 if 语句的确切格式之前已在同一个批处理文件中成功使用(我不确定之后)。通过放置 if "file2exist"=="true" echo true
的语句,我也知道它确实具有 "true"
的值这一事实。现在我将上一句的代码放在第 4 行和第 5 行之间,计算机进行了回显。这意味着第 4 行以某种方式被忽略了? (1-3行和10-11行有效,6-8行好像完全跳过了)
出了什么问题?
我先谢谢你了。非常感谢任何建议。
mkdir "0_%ModName%_Mod(%Version%)\"
mkdir "0_%ModName%_Mod(%Version%)\File1\"
echo.>"0_%ModName%_Mod(%Version%)\File1\Place_File_1_Here.txt"
if "file2exist"=="true" goto filetwostore
goto startbatting
:filetwostore
mkdir 0_%ModName%_Mod(%Version%)\File2\
echo.>"0_%ModName%_Mod(%Version%)\File2\Place_File_2_Here.txt"
:startbatting
echo Writing Batch File...
echo.>"Install-Uninstall.bat"
if "file2exist"=="true" goto filetwostore
等同于
if 1==2 goto filetwostore
如果两个不同的字符串不同,则它们不能相等
也许,你需要
if "%file2exist%"=="true" goto filetwostore
比较变量值,而不是变量名