如何从批处理文件启动Minecraft和Valorant?

问题描述 投票:0回答:1

昨天晚上,我决定尝试编码一个批处理文件。我使用了一些参考资料和一些在线演练,最后做出了下面的程序。

echo off
Title Log into CMD

:home
color 0A
echo ==================
echo.
echo [1] Log In
echo [2] Exit
set /p login=
if %login%==1 goto 1
if %login%==2 goto 2
goto error

:1
echo.
echo ==================
echo.
set and=if
set /p name=Enter your name: 
set /p pass=Enter your password: 
if %name%==Bob %and% %pass%==***** echo Welcome, Omid
if not %name%==Bob goto no
if not %pass%==***** goto no
goto GameMenu

:no
echo You're not Bob!
pause
echo Goodbye!
pause
exit

:2
exit

:error
echo You have to select a valid option!

:GameMenu
Title Game Menu
echo.
echo ==================
echo.
echo [1] Minecraft
echo [2] krunker.io
echo [3] Valorant
set /p gc=Enter the number of the game you would like to play:
if %gc%==1 goto Minecraft
if %gc%==2 goto krunker
if%gc%==3 goto Valorant
goto error

:Minecraft
start MinecraftLauncher.exe
exit

:krunker
start https://www.krunker.io/
exit

:Valorant
start RiotClientServices.exe
exit

这个程序很简单,你用用户名和密码登录,然后引出一个要打开的游戏目录。krunker.io可以用,但是我不知道怎么调用Minecraft和Valorant。打开游戏的进程是我叫的。例如,MinecraftLauncher.exe就是会启动Minecraft的进程名称。当我从菜单中选择Minecraft时,它给出了错误信息'Windows无法找到 "MinecraftLauncher.exe "确保你输入的名称是正确的,然后再试一次。`这是奇怪的,因为这是启动器的字面名称。我想知道是否有人有更多的经验可以帮助我。

batch-file minecraft
1个回答
0
投票

你必须通过路径来初始化应用程序。下面是一个步骤。

cd/
cd "Program Files (x86)/Minecraft"
start MinecraftLauncher.exe

你必须确保cmd在 c:\ 使用 cd/然后进入启动器文件位置并启动它。你可以通过使用 start/d.所以,这是你的代码。

@echo off
Title Log into CMD

:home
color 0A
echo ==================
echo.
echo [1] Log In
echo [2] Exit
set /p login=
if %login%==1 goto 1
if %login%==2 goto 2
goto error

:1
echo.
echo ==================
echo.
set and=if
set /p name=Enter your name: 
set /p pass=Enter your password: 
if %name%==Bob %and% %pass%==***** echo Welcome, Omid
if not %name%==Bob goto no
if not %pass%==***** goto no
goto GameMenu

:no
echo You're not Bob!
pause
echo Goodbye!
pause
exit

:2
exit

:error
echo You have to select a valid option!

:GameMenu
Title Game Menu
echo.
echo ==================
echo.
echo [1] Minecraft
echo [2] krunker.io
echo [3] Valorant
set /p gc=Enter the number of the game you would like to play:
if %gc%==1 goto Minecraft
if %gc%==2 goto krunker
if%gc%==3 goto Valorant
goto error

:Minecraft
cd/
start/d "C:\Program Files (x86)\Minecraft" MinecraftLauncher.exe
exit

:krunker
start https://www.krunker.io/
exit

:Valorant
cd/
start/d "C:\Program Files (x86)\*VALORANT LAUNCHER FOLDER*" RiotClientServices.exe
exit

而你的登录系统是坏的 如果你输入除1或2以外的任何一个键,你会直接到 :GameMenu可以很容易地解决,把 :error 或在文件的末尾使用 goto home 之前 echo You have to select a valid option!希望对你有所帮助。

© www.soinside.com 2019 - 2024. All rights reserved.