Multiple choices menu on batch file?

后端 未结 13 1684
盖世英雄少女心
盖世英雄少女心 2020-11-28 12:56

Hi I want to make a batch file menu, that asks \'Select app you want to install?\' for example

  1. App1
  2. App2
  3. App3
  4. App4
  5. App5
13条回答
  •  臣服心动
    2020-11-28 13:50

    There is actually an extremely easy way to do this.

    @echo off
    echo Which app do you want to install?
    echo [APP 1]
    echo [APP 2]
    echo [APP 3]
    echo.
    echo Type 1, 2, or 3.
    set /p "AppInstaller=>"
    if %AppInstaller%==1 goto 1
    if %AppInstaller%==2 goto 2
    if %AppInstaller%==3 goto 3
    :1
    [INSTALL CODE]
    :2
    [INSTALL CODE]
    :3
    [INSTALL CODE]
    

    The menu, when coded like this, will look like this:

    Which app do you want to install?
    [APP 1]
    [APP 2]
    [APP 3]
    
    Type 1, 2, or 3.
    >_
    

    The code sets the variable AppInstaller to 1, 2, or 3. The file determines this and redirects you to an installer for each one.

提交回复
热议问题