基本上,我正在创建一个服务器,并帮助我的朋友加入它(不要评判,感觉就像 Minecraft 游戏一样,哈哈),所以我想制作一个 .bat 文件来自动(稍微)执行此操作,到目前为止就是这样,但是当我到达 if exist 时,命令提示符就会退出,有什么想法吗?
@echo off
echo Hello there
timeout 2
echo Do not close this down if it tells you not to!!
timeout 2
echo click any key to download the program
start chrome.exe http://launcher.technicpack.net/launcher4/355/TechnicLauncher.exe
ping localhost -n 3 >nul
echo star my github project pls
start chrome.exe https://github.com/HawkSP/HawkSP.github.io
echo this next command is now going to wait for u game to download
pause
if exist %USERPROFILE%\Downloads\TechnicLauncher.exe (
pause
start %USERPROFILE%\Downloads\TechnicLauncher.exe
ping localhost -n 3 >nul
echo click install
echo wait
ping localhost -n 1 >nul
echo wait
ping localhost -n 1 >nul
echo wait
ping localhost -n 1 >nul
echo wait
ping localhost -n 1 >nul
echo wait
ping localhost -n 1 >nul
echo wait
ping localhost -n 1 >nul
echo wait
ping localhost -n 1 >nul
echo wait
ping localhost -n 1 >nul
echo wait
ping localhost -n 1 >nul
echo wait
ping localhost -n 1 >nul
echo wait
ping localhost -n 1 >nul
echo wait
ping localhost -n 1 >nul
echo wait
ping localhost -n 1 >nul
echo wait
ping localhost -n 3 >nul
echo enter Mojang Account email
ping localhost -n 3 >nul
echo enter Mojang Account Password
echo dont click continue if you havent entered ur details
pause
echo CLICK "MODPACKS"
timeout 2
echo Cick on the "Add Pack or Search"
timeout 1
echo TYPE "HEXXIT" INTO THE BOX"
timeout 2
echo Hit "Enter"
timeout 2
echo Hit "Install"
echo There will now be a 30 second time out
timeout 30
echo When your ready for the next step click enter
pause
echo Click Multiplayer
timeout 3
echo Direct Connect or Add Server
timeout 2
echo Enter this IP
timeout 1
echo
timeout 5
echo congrats you have done it :)))
pause
) else (
pause
)
我也尝试过把它放在“ ”中
答案1
当我进入if exist
命令提示符时,它就退出了
echo congrats you have done it :)))
上述语句包含)
会提前终止您的if
... 语句的字符
用。。。来代替
echo congrats you have done it :^)^)^)
其中^
是转义字符。
进一步阅读
- Windows CMD 命令行的 AZ 索引
- Windows CMD 命令的分类列表
- 句法- 转义字符、分隔符和引号。
- 语法括号- 使用括号/方括号对表达式进行分组