批量打开错误的文件类型

时间:2013-08-04 11:25:08

标签: batch-file

所以这是我的完整代码:

@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文件,名称完全相同。我无法重命名文件。所以基本上我问的是如何打开特定的文件类型。

由于

2 个答案:

答案 0 :(得分:0)

首先转到正确的目录,然后启动KSP:

,而不是启动C:\....\KSP.exe
cd "C:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program"
KSP.exe

答案 1 :(得分:-1)

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

将其视为可操作的程序

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

多数民众赞成。真。

其次:

使用Choice命令

您继续使用set /p choice会更好。

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

代码:

@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

希望有所帮助。莫纳