I have 16 different powershell scripts which install applications. How can I create a single batch file to ask for user input for selecting the powershell script to run?
Example:
I want to install only one application, so the batch script will ask for an input and I will type visualstudio. It will then run the appropriate powershell script to install Visual Studio.
SetLocal
@echo on
:menu
CHOICE /C VCNE /M "[V]isualStudio, [N]otePad, [c]hrome, [E]xit"
set answer=%CHOICE%
if /i "%answer:~,1%" EQU "V" goto visualstudio
if /i "%answer:~,1%" EQU "C" goto chrome
if /i "%answer:~,1%" EQU "N" goto notepad
if /i "%answer:~,1%" EQU "E" goto Exit
:chrome
C:
cd\
cd PowerShell
powershell -file Chrome.ps1
goto Menu
:visualstudio
C:
cd\
cd PowerShell
powershell -file visualstudio.ps1
goto Menu
:notepad
C:
cd\
cd PowerShell
powershell -file visualstudio.ps1
goto Menu
:Exit
exit
choice /?which will give you all the flexibility you appear to require - and all single-key.answeris empty, so you fall into the:chromeroutine; where does%CHOICE%come from? have you read the help of thechoicecommand that appears when typingchoice /?into a command prompt window?