Jump to content

Recommended Posts

Posted

I wrote a little menu batch to make the selection of what to install a bit easier.

It expects you to have sub folders for every application containing a file _SetupInfo.txt containing a one row file description and a file _SetupBatch.bat with the typical setup commands for unattended installation and of course the setup file itself.

That way you avoid editing the batch files for installation if you want to add or remove a specific application on your cd.

Please note that CHOICE.exe from the W2K resource kit is required.

I'm sure the whole thing can be streamlined a little more especially the dummy FOR commands.

We need the V switch for delayed variable expansion (or whatever its called in the english windows)

CallMenu.bat :

@ECHO OFF
CLS
CMD /V:ON /C Menu.bat

Menu.bat :

@ECHO OFF
CLS
SETLOCAL
rem --- Z is used to avoid problems with the offset later on ---
SET Characters=z1234567890abcdefghijklmnopqrstuvwx
SET Choices=y
SET /A ItemsCount=0
rem -- Insert your applications path below --
FOR /R Applications %%i IN (_SetupInfo*.txt) DO SET /A ItemsCount+=1 & FOR /F "delims=xxx" %%n in (%%~fi) DO SET ItemText!ItemsCount!=%%n & SET ItemOption!ItemsCount!=x& SET ItemSetup!ItemsCount!=%%~dpi_SetupBatch*.bat
FOR /L %%j IN (1,1,%ItemsCount%) DO SET Choices=!Choices!!Characters:~%%j,1!

:Menu
CLS
ECHO.
ECHO.
FOR /L %%k IN (1,1,%ItemsCount%) DO ECHO !Characters:~%%k,1!. !ItemOption%%k! !ItemText%%k!
ECHO.
Choice.exe /C:%Choices% /N /T:Y,20 Toggle selection with keys. Press Y to continue (20 Sec..)
IF %Errorlevel% LEQ 1 GOTO End
SET /A ChoiceMade=%Errorlevel% - 1
rem --- Dummy FOR Commands to append number to ItemOption ---
FOR /L %%l IN (%ChoiceMade%,1,%ChoiceMade%) DO IF "!ItemOption%%l!"=="x" (SET ItemOption%%l=_& GOTO Menu)
FOR /L %%m IN (%ChoiceMade%,1,%ChoiceMade%) DO IF "!ItemOption%%m!"=="_" (SET ItemOption%%m=x& GOTO Menu)
GOTO Menu

:End
FOR /L %%n IN (1,1,%ItemsCount%) DO IF "!ItemOption%%n!"=="x" CMD /C !ItemSetup%%n!
ECHO End..
ENDLOCAL

A typical example of how your CD would look like:

$OEM$\$1\Install\Applications\AdobeRdr\

_SetupInfo.txt

_SetupBatch.bat

AdbeRdr60_deu_full.exe

_SetupInfo.txt content:

Adobe Reader 6.0 Full Version

_SetupBatch.bat content:

@ECHO OFF
ECHO.
ECHO Installing
TYPE _SetupInfo.txt
ECHO Please wait...
START /wait AdbeRdr60_deu_full.exe -p"-s /v\"/qn\""

Have fun with it and post your improvement tips :)

edit : some typos and ECHO in final execution


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...