Application Installer with user parameter prompts

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
BILL Dos
Posts: 12
Joined: 22 Sep 2009 11:49
Location: USA

Application Installer with user parameter prompts

#1 Post by BILL Dos » 29 Nov 2009 15:34

Hey Guys , Have written a batch installer with 3 parameter prompts to install 1 of 3 .exe files, which works and installs the app but at end of batch instead of stopping and saying congrats the console just flashes and disappears off the screen, any Help would be greatly appreciated. Thanks!, Bill

Code: Select all

@Echo Off 
CLS && COLOR 4E
ECHO Application Installer with user parameter prompts
ECHO+
ECHO+                                                                     
ECHO  SELECT your Numbered .exe Application to Install..             
:MENU
ECHO+
ECHO+
ECHO 1 = File1
ECHO 2 = File2
ECHO 3 = File2
ECHO+
SET /P M=Type: 1, 2, or 3, then press ENTER:
IF %M%==1 GOTO File1
IF %M%==2 GOTO File2
IF %M%==3 GOTO File3
:File1
start /wait %windir%\Installs\File1.exe
GOTO :EOF
:File2
start /wait %windir%\Installs\File2.exe
GOTO :EOF
:File3
start /wait %windir%\Installs\File3.exe
:EOF
pause
Congratulations! Your Application has successfully installed.
EXIT
     

avery_larry
Expert
Posts: 391
Joined: 19 Mar 2009 08:47
Location: Iowa

#2 Post by avery_larry » 02 Dec 2009 13:49

:eof is a "special" label that signifies the very end of the file. So:

goto :eof

skips your :eof label and goes to the end of the file.

I *think* that this will work:

goto eof

HOWEVER, just change all :eof references to :end instead and you'll be fine.

BILL Dos
Posts: 12
Joined: 22 Sep 2009 11:49
Location: USA

Got it figured out..

#3 Post by BILL Dos » 02 Dec 2009 19:06

Thanks! for the reply Larry, but after much head scratching solved my problem..
Turns out that all I needed to do was use the MENU label
So instead of GOTO :EOF I used
GOTO :MENU
and then it worked like a charm! even Added a few more apps afterwards
to run then converted with a batch compiler to .exe and life was good.

Again Thanks for the help..

DosItHelp
Expert
Posts: 239
Joined: 18 Feb 2006 19:54

#4 Post by DosItHelp » 03 Dec 2009 23:32

The menu below discovers the menu items within the batch. It allow adding new menu items as single labeled units without having to change the menu loop itself.

Code: Select all

@ECHO OFF

:menuLOOP
echo.
echo.= Menu =================================================
echo.
for /f "tokens=1,2,* delims=_ " %%A in ('"findstr /b /c:":menu_" "%~f0""') do echo.  %%B  %%C
set choice=
echo.&set /p choice=Make a choice or hit ENTER to quit: ||GOTO:EOF
echo.&call:menu_%choice%
GOTO:menuLOOP

::-----------------------------------------------------------
:: menu functions follow below here
::-----------------------------------------------------------

:menu_1   Install File1
start /wait "%windir%\Installs\File1.exe"
GOTO:EOF

:menu_2   Install File2
start /wait "%windir%\Installs\File2.exe"
GOTO:EOF

:menu_

:menu_3   Install File3
start /wait "%windir%\Installs\File3.exe"
GOTO:EOF

Output:

Code: Select all

= Menu =================================================

  1  Install File1
  2  Install File2

  3  Install File3

Make a choice or hit ENTER to quit:

Post Reply