Created
February 7, 2021 11:36
-
-
Save farsil/10facba6681bbbe69202ce27bec69415 to your computer and use it in GitHub Desktop.
DOS Installer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DIM ProgramName AS STRING | |
DIM ProgramCommand AS STRING | |
DIM SetupCommand AS STRING | |
DIM DestDirectory AS STRING | |
DIM ArchiveFile AS STRING | |
' read installation settings from INSTALL.CFG | |
ConfigFile = FREEFILE | |
OPEN "INSTALL.CFG" FOR INPUT AS ConfigFile | |
DO WHILE NOT EOF(ConfigFile) | |
LINE INPUT #ConfigFile, Line$ | |
EqualsIndex% = INSTR(Line$, "=") | |
IF EqualsIndex% THEN | |
Option$ = LCASE$(LEFT$(Line$, EqualsIndex% - 1)) | |
Value$ = RIGHT$(Line$, LEN(Line$) - EqualsIndex%) | |
IF Option$ = "progname" THEN | |
ProgramName = Value$ | |
ELSEIF Option$ = "destdir" THEN | |
DestDirectory = Value$ | |
ELSEIF Option$ = "archive" THEN | |
ArchiveFile = Value$ | |
ELSEIF Option$ = "progcmd" THEN | |
ProgramCommand = Value$ | |
ELSEIF Option$ = "setupcmd" THEN | |
SetupCommand = Value$ | |
END IF | |
END IF | |
LOOP | |
CLOSE ConfigFile | |
' ask user to confirm or change installation directory | |
PRINT "Installation directory (" + DestDirectory + "): "; | |
INPUT "", UserInput$ | |
IF UserInput$ <> "" THEN | |
DestDirectory = UCASE$(UserInput$) | |
END IF | |
' split destination directory into drive and directory | |
DIM DestDrive AS STRING | |
ColonIndex% = INSTR(DestDirectory, ":") | |
IF ColonIndex% THEN | |
DestDrive = LEFT$(DestDirectory, ColonIndex%) | |
END IF | |
DestDirectory = RIGHT$(DestDirectory, LEN(DestDirectory) - ColonIndex%) | |
' perform the installation | |
SHELL "instcmd " + ArchiveFile + " " + DestDrive + " " + DestDirectory + _ | |
" " + CHR$(34) + ProgramName + CHR$(34) + " " + ProgramCommand + _ | |
" " + SetupCommand |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[install] | |
progname=Software title | |
archive=SOFTWARE.ZIP | |
destdir=C:\SOFTWARE | |
progcmd=SOFTWARE | |
setupcmd=SETUP |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: Arguments passed from INSTALL.EXE | |
:: %1 Archive filename | |
:: %2 Destination drive | |
:: %3 Destination directory | |
:: %4 Program name | |
:: %5 Program command | |
:: %6 Setup command (optional) | |
@echo off | |
:: this file should not be run directly | |
set WRONGFILE= | |
if [%1] == [] set WRONGFILE=1 | |
if [%2] == [] set WRONGFILE=1 | |
if [%3] == [] set WRONGFILE=1 | |
if [%4] == [] set WRONGFILE=1 | |
if [%5] == [] set WRONGFILE=1 | |
if [%WRONGFILE%] == [1] goto wrongfile | |
:: decompress, terminate immediately on error | |
pkunzip -ode %1 %2%3 | |
if errorlevel 1 goto fail | |
:: change current drive and path to destination | |
%2 | |
cd %3 | |
:: do not print setup information if setup command is blank | |
if [%6] == [] goto nosetup | |
:: message to display when there is a setup command | |
echo. | |
echo Type %5 to run "%4" or %6 for configuration. | |
echo. | |
goto end | |
:nosetup | |
:: message to display when there is no setup command | |
echo. | |
echo Type %5 to run "%4". | |
echo. | |
goto end | |
:wrongfile | |
:: message to display when this file is run directly | |
echo. | |
echo Please run INSTALL.EXE | |
echo. | |
goto end | |
:fail | |
:: message to display when pkunzip fails to decompress | |
echo. | |
echo Installation failed! | |
echo. | |
:end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment