按任意键后如何终止应用程序,它将返回菜单?

时间:2017-08-04 07:19:43

标签: batch-file if-statement

如何创建允许用户选择要运行的应用程序的批处理文件,然后它将提示"按任意键继续",按任意键后,所选应用程序将被终止并将回到菜单?

@echo off
title MENU
:menu
cls
echo.
echo SELECT APPLICATION YOU WANT TO RUN:
echo ===================================
echo.
echo 1. Google Chrome
echo 2. APP 2
echo 3. EXIT
echo.
echo ===================================
echo.

set /p web= Enter Number of Choice:

if "%web%"=="1" start chrome.exe (pause)
if "%web%=='2' start app2.exe (pause)
if "%web%"=='3' exit

goto menu

pause

2 个答案:

答案 0 :(得分:0)

尝试这样的事情:

@ECHO OFF
TITLE MENU
:menu
CLS
ECHO.
ECHO SELECT APPLICATION YOU WANT TO RUN:
ECHO ===================================
ECHO.
ECHO 1. Google Chrome
ECHO 2. APP 2
ECHO 3. EXIT
ECHO.
ECHO ===================================
ECHO.

SET /p web= Enter Number of Choice:

IF "%web%" EQU "1" (
  START chrome.exe
) ELSE IF "%web% EQU "2" (
  START app2.exe
) ELSE IF "%web%" NEQ "3" GOTO menu

PAUSE

答案 1 :(得分:0)

...
if "%web%"=="1" start chrome.exe & pause & taskkill /IM chrome.exe
...