批量不能很好地工作。如果存在

时间:2012-03-14 18:43:17

标签: if-statement batch-file dos

尝试使用某些批处理。

@ echo off
IF EXIST %CD%\Minecraft.exe
Minecraft.exe
IF NOT exist %CD%\Minecraft.exe
wget.exe https://s3.amazonaws.com/MinecraftDownload/launcher/Minecraft.exe
Minecraft.exe
pause

我做错了什么?当我运行它时,CMD就会关闭。

1 个答案:

答案 0 :(得分:8)

  

我做错了什么?

您可以阅读IF命令if /?的帮助。

它解释了if期望所有在一行

@echo off
IF EXIST %CD%\Minecraft.exe Minecraft.exe
IF NOT exist %CD%\Minecraft.exe wget.exe https://s3.amazonaws.com/MinecraftDownload/launcher/Minecraft.exe Minecraft.exe
pause

或使用ELSE

@echo off
IF EXIST %CD%\Minecraft.exe (
  Minecraft.exe
) ELSE (
  wget.exe https://s3.amazonaws.com/MinecraftDownload/launcher/Minecraft.exe Minecraft.exe
)
pause