home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
swCHIP 1991 January
/
swCHIP_95-1.bin
/
demo
/
wit4711
/
witsetup.ms_
/
witsetup.ms
Wrap
Text File
|
1995-12-09
|
9KB
|
294 lines
'**************************************************************************
'* WiT Setup
'**************************************************************************
'$DEFINE DEBUG ''Define for script development/debugging
'$INCLUDE 'setupapi.inc'
'$INCLUDE 'msdetect.inc'
''Dialog ID's
CONST WELCOME = 100
CONST ASKQUIT = 200
CONST DESTPATH = 300
CONST EXITFAILURE = 400
CONST EXITQUIT = 600
CONST EXITSUCCESS = 700
CONST OPTIONS = 800
CONST APPHELP = 900
CONST BADPATH = 6400
CONST AUTOEXEC = 7802
''Bitmap ID
CONST LOGO = 1
''Other IDs
CONST MB_YESNO = 4
CONST MB_YESNOCANCEL = 3
CONST MB_ICONQUESTION = 32
CONST MB_ICONEXCLAMATION = 48
CONST IDCANCEL = 2
CONST IDYES = 6
CONST IDNO = 7
GLOBAL SRC$ ''Source directory
GLOBAL DEST$ ''Default destination directory.
GLOBAL OPTCUR$ ''Option selection from option dialog.
GLOBAL TMPDIR$ ''TMP environment variable
DECLARE SUB Install
DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
INIT:
SRC$ = GetSymbolValue("STF_SRCDIR")
CUIDLL$ = "mscuistf.dll" ''Custom user interface dll
HELPPROC$ = "FHelpDlgProc" ''Help dialog procedure
SetBitmap CUIDLL$, LOGO
SetTitle "WiT Setup"
szInf$ = GetSymbolValue("STF_SRCINFPATH")
IF szInf$ = "" THEN
szInf$ = GetSymbolValue("STF_CWDDIR") + "WITSETUP.INF"
END IF
ReadInfFile szInf$
DEST$ = "C:\WIT"
WELCOME:
sz$ = UIStartDlg(CUIDLL$, WELCOME, "FInfoDlgProc", APPHELP, HELPPROC$)
IF sz$ = "CONTINUE" THEN
UIPop 1
ELSE
GOSUB ASKQUIT
GOTO WELCOME
END IF
''CHECKWIN32S:
'' w32sysdll$ = GetWindowsSysDir() + "W32SYS.DLL"
'' exist% = DoesFileExist(w32sysdll, femExists)
'' IF exist% = 0 THEN
'' msg$ = "WIN32S is not installed on the system. "
'' msg$ = "You must install WIN32S before installing WiT."
'' i% = DoMsgBox(msg$, "Error", MB_OK+MB_TASKMODAL+MB_ICONHAND)
'' dlg% = EXITFAILURE
'' GOTO QUITL1
'' END IF
GETPATH:
SetSymbolValue "EditTextIn", DEST$
SetSymbolValue "EditFocus", "ALL"
GETPATHL1:
sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$)
DEST$ = GetSymbolValue("EditTextOut")
IF sz$ = "CONTINUE" THEN
IF IsDirWritable(DEST$) = 0 THEN
GOSUB BADPATH
GOTO GETPATHL1
END IF
IF DoesDirExist(DEST$) THEN
msg$ = "The specified directory already exists! "
msg$ = msg$ + "Do you want to overwrite the directory?"
i% = DoMsgBox(msg$, "Confirm Overwrite", MB_YESNO+MB_APPLMODAL+MB_ICONQUESTION)
IF i% = IDYES THEN
''RemoveDir DEST$, cmoForce
ELSE
GOTO GETPATHL1
END IF
END IF
UIPop 1
ELSEIF sz$ = "REACTIVATE" THEN
GOTO GETPATHL1
ELSEIF sz$ = "BACK" THEN
UIPop 1
GOTO WELCOME
ELSE
GOSUB ASKQUIT
GOTO GETPATH
END IF
CHECKSIZE:
l& = GetFreeSpaceForDrive(DEST$)
IF l& < 8388608 THEN
msg$ = "WiT requires 8Mb of disk space to install. "
msg$ = msg$ + "There is only " + STR$(l&/1048576) + "Mb of free disk space on the drive specified. "
msg$ = msg$ + "If you choose Ok to continue, it may run out of disk space."
i% = DoMsgBox(msg$, "WARNING!", MB_YESNO+MB_TASKMODAL+MB_ICONHAND)
IF i% = IDNO THEN
GOTO GETPATH
END IF
END IF
CTL3D:
SRC$ = GetSymbolValue("STF_SRCDIR")
CTLDEST$ = GetWindowsSysDir() + "CTL3DV2.DLL"
CTLSRC$ = SRC$ + "CTL3DV2.DLL"
destdate$ = GetDateOfFile(CTLDEST$)
srcdate$ = GetDateOfFile(CTLSRC$)
IF srcdate$ > destdate$ THEN
exist% = DoesFileExist(CTLDEST$, femExists+femReadWrite)
IF NOT exist% = 0 THEN
msg$ = "SETUP detects that CTL3DV2.DLL is not up to date. "
msg$ = msg$ + "Do you want SETUP to update the file? "
msg$ = msg$ + "If you choose yes, any applications using CTL3DV2.DLL "
msg$ = msg$ + "may behave strangely in the current session. "
msg$ = msg$ + "Choose No if you want to continue without updating the file. "
msg$ = msg$ + "Choose Cancel to quit SETUP. "
i% = DoMsgBox(msg$, "Update CTL3DV2.DLL?", MB_YESNOCANCEL+MB_TASKMODAL+MB_ICONQUESTION)
IF i% = IDCANCEL THEN
dlg% = EXITFAILURE
GOTO QUITL1
ELSEIF i% = IDNO THEN
GOTO NOUPDATE
END IF
END IF
RemoveFile CTLDEST$, cmoNone
CopyFile CTLSRC$, CTLDEST$, cmoVital, 0
NOUPDATE:
END IF
TMPPATH:
TMPDIR$ = GetEnvVariableValue("tmp")
IF TMPDIR$ = "" THEN
TMPDIR$ = MakePath(DEST$, "TMP")
ELSE
i% = DoesDirExist(TMPDIR$)
IF i% = 0 THEN
msg$ = "The TMP environment variable points to a non-existent directory. "
msg$ = msg$ + "SETUP will modify the variable to suit WiT."
i% = DoMsgBox(msg$, "TMP directory", MB_OK+MB_TASKMODAL+MB_ICONHAND)
TMPDIR$ = MakePath(DEST$, "TMP")
END IF
END IF
Install
AUTOEXEC:
SetSymbolValue "AutoFileName", "C:\AUTOEXEC.BAT"
SetSymbolValue "TmpFileName", GetSymbolValue("STF_CWDDIR") + "AUTOEXEC.TMP"
SetSymbolValue "WiTPath", DEST$
SetSymbolValue "WiTTmp", TMPDIR$
SetSymbolValue "HostType", "WIN31"
AUTOL1:
sz$ = UIStartDlg(CUIDLL$, AUTOEXEC, "FAutoDlgProc", APPHELP, HELPPROC$)
IF sz$ = "REACTIVATE" THEN
GOTO AUTOL1
ELSEIF sz$ = "CONTINUE" THEN
UIPop 1
RemoveFile "C:\AUTOEXEC.WIT", cmoForce
BackupFile "C:\AUTOEXEC.BAT", "AUTOEXEC.WIT"
NewAuto$ = GetSymbolValue("TmpFileName")
CopyFile NewAuto$, "C:\AUTOEXEC.BAT", cmoNone, 0
RemoveFile NewAuto$, cmoForce
ELSE
UIPop 1
NewAuto$ = GetSymbolValue("TmpFileName")
CopyFile NewAuto$, "C:\AUTOEXEC.WIT", cmoNone, 0
RemoveFile NewAuto$, cmoForce
END IF
UIPop 1
QUIT:
ON ERROR GOTO ERRQUIT
IF ERR = 0 THEN
msg$ = "You should exit Windows and REBOOT the system in order for WiT to work. "
msg$ = msg$ + "If you chose not to update AUTOEXEC.BAT, "
msg$ = msg$ + "modify the file yourself and reboot the system."
i% = DoMsgBox(msg$, "WiT Setup", MB_OK+MB_APPLMODAL+MB_ICONEXCLAMATION)
END
ELSEIF ERR = STFQUIT THEN
dlg% = EXITQUIT
ELSE
dlg% = EXITFAILURE
END IF
QUITL1:
sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
IF sz$ = "REACTIVATE" THEN
GOTO QUITL1
END IF
UIPop 1
END
ERRQUIT:
i% = DoMsgBox("Setup sources were corrupted!", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
END
BADPATH:
sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
IF sz$ = "REACTIVATE" THEN
GOTO BADPATH
END IF
UIPop 1
RETURN
ASKQUIT:
sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
IF sz$ = "EXIT" THEN
UIPopAll
ERROR STFQUIT
ELSEIF sz$ = "REACTIVATE" THEN
GOTO ASKQUIT
ELSE
UIPop 1
END IF
RETURN
'**
'** Purpose:
'** Builds the copy list and performs all installation operations.
'** Arguments:
'** none.
'** Returns:
'** none.
'*************************************************************************
SUB Install STATIC
SrcDir$ = GetSymbolValue("STF_SRCDIR")
CreateDir DEST$, cmoNone
''OpenLogFile MakePath(DEST$, "LOGFILE.OUT"), 0
''WriteToLogFile ""
''WriteToLogFile " User chose as destination directory: '" + DEST$ + "'"
''WriteToLogFile ""
AddSectionFilesToCopyList "Files", SrcDir$, DEST$
CopyFilesInCopyList
CreateProgmanGroup "WiT", "wit", cmoNone
ShowProgmanGroup "WiT", 1, cmoNone
CreateProgmanItem "WiT", "WiT", ""+MakePath(DEST$,"BIN\WIT.EXE"),",,,,"+MakePath(DEST$,"BIN"), cmoOverwrite
CreateProgmanItem "WiT", "WiT Builder", ""+MakePath(DEST$,"BIN\WITBUILD.EXE"), ",,,,"+MakePath(DEST$,"SERVERS"), cmoOverwrite
''CloseLogFile
END SUB
'**
'** Purpose:
'** Appends a file name to the end of a directory path,
'** inserting a backslash character as needed.
'** Arguments:
'** szDir$ - full directory path (with optional ending "\")
'** szFile$ - filename to append to directory
'** Returns:
'** Resulting fully qualified path name.
'*************************************************************************
FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
IF szDir$ = "" THEN
MakePath = szFile$
ELSEIF szFile$ = "" THEN
MakePath = szDir$
ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
MakePath = szDir$ + szFile$
ELSE
MakePath = szDir$ + "\" + szFile$
END IF
END FUNCTION