@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
回答
下面的代码让用户选择他们是否想要为Firefox选择y以打开Chrome或Firefox和程序里面的N代表铬,您可以更改输入到1或2或者你喜欢什么。
检查你的路是正确的.EXE文件
(路径是在我的电脑上不同)
@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
不,先生其不工作,如果我输入Y都计划得到执行 – Lynus
我有一个错字,我现在编辑我的答案尝试 –
你可以做这样一个菜单:
@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
你也可以使用选择命令:
@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%"
我希望当用户输入1个中的第一个节目是执行问题得以解决
@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
2时,第二
它的作品谢谢你 – Lynus
的“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必须在同一行中使用圆括号。
- 1. 如何在批处理编程中使用if-else语句?
- 2. if/else-if语句如何处理?
- 3. 批处理 - 在IF语句
- 4. If/then/else语句批量
- 5. 处理大量的if-else语句,转
- 6. if else批处理文件中的语句格式
- 7. Ajax调用错误处理功能或if-else语句
- 8. 使用IF/ELSE语句
- 9. 如何使用Array和if else语句?
- 10. 使用Java 8流处理嵌套的if/else语句
- 11. 使用的 “如果/ ELSEIF /其他” 与 “的if/else {if/else语句}”
- 12. 批处理脚本中的IF语句
- 13. if else if else语句(JS)
- 14. 用的if else语句
- 15. 如何在此if/else语句中添加if/else语句?
- 16. 如何用if语句和输入在批处理文件中调用另一批处理文件?
- 17. IF语句批处理脚本
- 18. iMacros if/else语句如何?
- 19. 如何使用if/else语句在UPDATE语句
- 20. If else语句
- 21. If/else语句
- 22. if else语句
- 23. 用If-Then-Else语句处理sas中的极端异常值
- 24. 在IF语句中使用OR WinXP批处理脚本
- 25. 批处理程序在尝试使用IF语句时关闭
- 26. 的if else语句
- 27. 使用IF语句处理回车键
- 28. 使用If语句处理Bool值
- 29. 如何在Oracle的where子句中使用IF THEN ELSE语句?
- 30. Windows批处理忽略的if else
解释你的问题多一点,你会得到什么样的错误,你想要达到什么目的。 –
代码中的if else语句无法得到执行 – Lynus
acrtually我想使一批来自哪个用户可以选择e.g如果用户选择1,firefox.exe启动内部批处理程序;并且如果用户选择2 chrome得到执行等等。 – Lynus