0

所以这是我的整个代码:

@echo off
cls
color fc
:Start
cls
echo Welcome to -{GAMELOADER}-
set/p u=Username:
if %u%==username goto Correct1
if not %u%==username goto Incorrect

:Incorrect
cls
echo You Have Entered Incorrect Pass And/Or Username!
set/p t=Try Again? (Y/N)
if %t%==Y goto Start
if %t%==y goto Start
if %t%==N goto Quit
if %t%==n goto Quit

:Correct1
set/p p=Password:
if %p%==password goto Open
if not %p%==password goto Incorrect

:Open
cls 
echo                 Games:
echo            ------------------------
echo            [1]Kerbal Space Program
echo            ------------------------
set/p g=Choice:
if %g%== 1 goto KSPEnd

:KSPEnd
start "" "C:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\KSP.exe"
cls
goto Quit

:Quit
cls
echo Goodbye
Timeout 1

但是代码会打开 .exe 和一个具有完全相同名称的 .txt 文件。我无法重命名文件。所以基本上我在问如何打开特定的文件类型。

谢谢

4

2 回答 2

0

不启动C:\....\KSP.exe,先到正确的目录,然后启动KSP:

cd "C:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program"
KSP.exe
于 2013-08-04T13:47:41.983 回答
-1

好的,我有两件事要给你。首先,我会给你想要的解决方案。

把它当作一个可运行的程序

rem To start Kerbal Space Program:
set Path=C:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program;%Path%
start KSP

而已。真的。

第二:

使用Choice命令

你继续使用set /pwherechoice会好很多。

为了方便起见,我用我会做的一切重新编写了你的​​代码。玩得开心!

代码 :

@echo off
cls
color fc
title -{GAMELOADER}-
:Start
echo Welcome to -{GAMELOADER}-
set/p u=Username:
if %u%==username goto Correct1
if not %u%==username goto Incorrect
set Er=Userid
goto :Crash
:Incorrect
cls
echo You Have Entered Incorrect Pass And/Or Username!
choice /c yn /m "Try Again?"
if %errorlevel%==1 goto Start
if %errorlevel%==2 goto Quit
set Er=Loop-End_of_stream
goto :Crash
:Correct1
set/p p=Password:
if %p%==password goto Open
if not %p%==password goto Incorrect
set Er=Passid
goto :Crash
:Open
cls 
echo                 Games:
echo            ------------------------
echo            [1]Kerbal Space Program
echo            ------------------------
echo.
Choice /c 1 /m "Game: "
if %errorlevel%==1 goto KSPEnd
set Er=Gameid
goto :Crash
:KSPEnd
set Path=C:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program;%Path%
start KSP
goto Quit
set Er=End_of_file___UNKNOWN
goto :Crash
:Quit
cls
echo Goodbye
Timeout 1
Exit
:Crash
Rem Always useful :)
Echo Program has crashed Error: %Er%
Pause 
Exit

希望有帮助。莫娜

于 2013-08-04T12:22:29.310 回答