@echo off
set /P user= Enter number:
echo You have entered %user%
if %user%
(
start "C:\Program Files\Mozilla Firefox\firefox.exe"
)
else if %user%
(
start "C:\Program Files\google chrome\chrome.exe"
)
else
Pause
答案 0 :(得分:1)
您可以使用菜单执行此操作:
@Echo OFF
Mode 60,12 & color 9E
Title Start and open a Program
:MENU
CLS
ECHO.
ECHO =====================================================
ECHO PRESS 1, 2 OR 3 to select your task, or 4 to EXIT.
ECHO =====================================================
ECHO.
ECHO 1 - Open Firefox
ECHO 2 - Open Chrome
ECHO 3 - Open Internet Explorer
ECHO 4 - EXIT
ECHO.
SET /P "user=Type 1, 2, 3, or 4 then press ENTER : "
IF "%user%"=="1" GOTO Firefox
IF "%user%"=="2" GOTO Chrome
IF "%user%"=="3" GOTO Internet Explorer
IF "%user%"=="4" GOTO EOF
GOTO MENU
:Firefox
start "" "Firefox.exe"
GOTO MENU
:Chrome
start "" "chrome.exe
GOTO MENU
:Internet Explorer
Start "" "iexplore.exe"
GOTO MENU
答案 1 :(得分:0)
下面的代码让用户可以通过为Firefox选择y来选择是否要打开chrome或Firefox,对于chrome可以选择n,您可以将输入更改为1或2或者您喜欢的任何内容。
检查您的路径是否与.exes
相符(我的电脑上的路径不同)
@echo off
set user=
set /P user=Type input y/n: %=%
pause
if "%user%" == "y" goto mozzila
if "%user%" == "n" goto chrome
:mozzila
cd C:\Program Files\Mozilla Firefox\
firefox.exe
:chrome
cd C:\Program Files\google chrome\
chrome.exe
Pause
答案 2 :(得分:0)
您也可以使用选择命令:
@Echo Off
Echo 1. Firefox
Echo 2. Chrome
Echo 3. Internet Explorer
Choice /C 123 /M "Please make your choice"
If ErrorLevel 3 (Set "BEP=Internet Explorer\iexplore.exe"
) Else If ErrorLevel 2 (Set "BEP=Google Chrome\chrome.exe"
) Else Set "BEP=Mozilla Firefox\firefox.exe"
If Exist "%ProgramFiles%\%BEP%" Start "" "%ProgramFiles%\%BEP%"
答案 3 :(得分:0)
我希望这能解决你的问题
@echo on
set /P user=Enter number:
echo You have entered %user%
IF /i "%user%" == "1" goto 1
IF /i "%user%" == "2" goto 2
:1
cd "C:\Program Files\Mozilla Firefox"
start firefox.exe
exit
:2
cd "C:\Program Files\google chrome"
start chrome.exe
exit
当用户输入1时,第一个程序在第二个
时执行答案 4 :(得分:0)
正确的格式" IF ... ELSE ..."是:
IF %user% (
start "C:\Program Files\Mozilla Firefox\firefox.exe"
) ELSE (
IF %user% (
start "C:\Program Files\google chrome\chrome.exe"
) ELSE ( sth. )
)
ELSE必须遵循同一行中的圆括号。