home *** CD-ROM | disk | FTP | other *** search
/ BBS 1 / BBS#1.iso / for-win / elastic1.arj / 32SINST.MST < prev    next >
Encoding:
Text File  |  1994-08-05  |  12.7 KB  |  436 lines

  1. '**************************************************************************
  2. '*                  MS Test script for Win32s setup program
  3. '**************************************************************************
  4.  
  5. '' $DEFINE DEBUG  ''Define for script development/debugging
  6.  
  7. '$INCLUDE 'setupapi.inc'
  8. '$INCLUDE 'msdetect.inc'
  9.  
  10. ''Dialog ID's
  11. CONST WELCOME                  = 100
  12. CONST ASKQUIT                  = 200
  13. CONST DESTPATH                 = 300
  14. CONST EXITFAILURE              = 400
  15. CONST EXITQUIT                 = 600
  16. CONST EXITSUCCESS              = 700
  17. CONST OPTIONS                  = 800
  18. CONST BADPATH                  = 6400
  19.  
  20. CONST HELPWELCOME              = 1000
  21. CONST VERPATH                  = 1100
  22. CONST EXITFAILNOTWIN31         = 1200
  23. CONST EXITFAILNOTENH           = 1300
  24. CONST EXITFAILNOTPAGING        = 1325
  25. CONST EXITFAILNOTINTEL         = 1350
  26. CONST FREECELLINST             = 1400
  27. CONST FREECELLINSTNOWIN32S     = 1450
  28. CONST FREECELLPATH             = 1500
  29. CONST HELPFREECELL             = 1600
  30.  
  31. CONST ERCONTINUE               = 8128
  32.  
  33. ''Bitmap ID
  34. CONST LOGO = 1
  35.  
  36. GLOBAL DESTSYS$      ''Windows\System directory.
  37. GLOBAL DEST32S$      ''Windows\System\Win32s directory
  38. GLOBAL DESTFREE$     ''Freecell directory
  39.  
  40. DECLARE SUB Install
  41. DECLARE SUB UpdateSystemIni
  42. DECLARE SUB RebootSystem
  43. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  44. DECLARE FUNCTION MakeSystemIni LIB "INIUPD.DLL" (arg1$, arg2$) AS INTEGER
  45. DECLARE FUNCTION RestartWindows LIB "INIUPD.DLL" AS INTEGER
  46. DECLARE FUNCTION OnWindowsNT LIB "INIUPD.DLL" AS INTEGER
  47. DECLARE FUNCTION PagingEnabled LIB "INIUPD.DLL" AS INTEGER
  48. DECLARE FUNCTION ShareEnabled LIB "INIUPD.DLL" AS INTEGER
  49. DECLARE FUNCTION IsWin32sLoaded LIB "INIUPD.DLL" (arg1$) AS INTEGER
  50. DECLARE FUNCTION ExitWindowsExec LIB "USER.EXE" (arg1$, arg2$) AS INTEGER
  51.  
  52. INIT:
  53.     CUIDLL$ = "mscuistf.dll"            ''Custom user interface dll
  54.     HELPPROC$ = "FHelpDlgProc"        ''Help dialog procedure
  55.     szOldVer$ ="1.00.000     "        ''Reserve space in string for version
  56.     WIN32ENABLED% = 0
  57.     GLOBAL AlwaysCopy%
  58.     AlwaysCopy% = 0
  59.     ON ERROR GOTO ERRNORMAL
  60.  
  61.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  62.  
  63.     SetBitmap CUIDLL$, LOGO
  64.     SetTitle "Microsoft Win32s Setup Program"
  65.  
  66.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  67.     IF szInf$ = "" THEN
  68.     szInf$ = GetSymbolValue("STF_CWDDIR") + "32sinst.inf"
  69.     END IF
  70.     ReadInfFile szInf$
  71.  
  72.     DESTSYS$ = GetWindowsSysDir()
  73.     DEST32S$ = DESTSYS + "WIN32S\"
  74.  
  75. '$IFDEF DEBUG
  76.     i% = SetSizeCheckMode(scmOnIgnore)    '' could use scmOff; def = scmOnFatal
  77.     WinDrive$ = MID$(GetWindowsDir, 1, 1)
  78.     IF IsDriveValid(WinDrive$) = 0 THEN
  79.     i% = DoMsgBox("Windows drive ('"+WinDrive$+"') is not a valid drive.", "DEBUG", MB_TASKMODAL+MB_ICONHAND+MB_OK)
  80.     GOTO QUIT
  81.     END IF
  82. '$ENDIF ''DEBUG
  83.  
  84. CHECK:
  85.     IF GetWindowsMajorVersion < 3 THEN
  86.     ExitCode% = EXITFAILNOTWIN31
  87.     GOTO QUIT
  88.     END IF
  89.     IF GetWindowsMajorVersion = 3 AND GetWindowsMinorVersion < 1 THEN
  90.     ExitCode% = EXITFAILNOTWIN31
  91.     GOTO QUIT
  92.     END IF
  93.     IF GetWindowsMajorVersion >= 4 THEN
  94.     ExitCode% = EXITSUCCESS
  95.     WIN32ENABLED% = 1
  96.     GOTO FREECELL
  97.     END IF
  98.     IF GetWindowsMode < 2  THEN
  99.     IF OnWindowsNT() THEN
  100.        ExitCode% = EXITFAILNOTINTEL    '' Running on Windows NT (on RISC)
  101.     ELSE
  102.        ExitCode% = EXITFAILNOTENH    '' Standard Mode Windows
  103.     END IF
  104.     GOTO QUIT
  105.     END IF
  106.     IF OnWindowsNT() THEN
  107.     ExitCode% = EXITSUCCESS
  108.     WIN32ENABLED% = 1
  109.     GOTO FREECELL
  110.     END IF
  111.     ExitCode% = EXITSUCCESS
  112.  
  113.     '' Get version of Win32s to be installed from version info in file
  114.     szNewVer$ = GetVersionOfFile( GetSymbolValue("STF_SRCDIR") + "WIN32S16.DLL" )
  115.  
  116.     '' Check if Win32s is partially installed
  117.     sz$ = GetIniKeyString (DESTSYS$ + "WIN32S.INI", "Win32s", "Setup")
  118.     '' If WIN32S.INI specifies Setup=0, then force complete Win32s file overwrite
  119.     IF sz$ = "0" THEN
  120.     AlwaysCopy% = 1
  121.     GOTO WELCOME
  122.     END IF
  123.     '' If WIN32S.INI is missing, try and reinstall Win32s files/recreate WIN32S.INI
  124.     IF sz$ <> "1" THEN
  125.     GOTO WELCOME
  126.     END IF
  127.  
  128.     '' If Win32s is already installed, get running version number
  129.     i% = DoesFileExist( DESTSYS$ + "W32SYS.DLL", femExists )
  130.     IF i% = 1 THEN
  131.     i% = IsWin32sLoaded( szOldVer$ )
  132.     ENDIF
  133.  
  134.     IF i% = 0 THEN
  135.     GOTO WELCOME
  136.     END IF
  137.     IF szNewVer$ > szOldVer$ THEN
  138.     GOTO WELCOME
  139.     END IF
  140.     WIN32ENABLED% = 1
  141.     GOTO FREECELL
  142.  
  143. WELCOME:
  144.     sz$ = UIStartDlg(CUIDLL$, WELCOME, "FInfoDlgProc", HELPWELCOME, HELPPROC$)
  145.     IF sz$ = "CONTINUE" THEN
  146.     UIPop 1
  147.     ELSE
  148.     GOSUB ASKQUIT
  149.     GOTO WELCOME
  150.     END IF
  151.  
  152.  
  153. GETWIN32SPATH:
  154.     IF PagingEnabled() = 0 THEN
  155.     i% = DoMsgBox("Use the Control Panel 386 Enhanced icon and configure Windows using the Virtual Memory option.", "Win32s requires Virtual Memory", MB_TASKMODAL+MB_ICONHAND+MB_OK)
  156.     ExitCode% = EXITFAILURE '' Enhanced mode but not paging
  157.     GOTO QUIT
  158.     END IF
  159.  
  160.     IF ShareEnabled() = 0 THEN
  161.     i% = DoMsgBox( "File-sharing must be enabled. Run SHARE.EXE before starting Windows or add SHARE.EXE to your AUTOEXEC.BAT file.", "Win32s Setup: SHARE.EXE is not loaded", MB_TASKMODAL+MB_ICONEXCLAMATION+MB_OK)
  162.     END IF
  163.  
  164.     SetSymbolValue "EditTextIn", DESTSYS$
  165.     SetSymbolValue "EditFocus", "END"
  166.  
  167. GETPATHL1:
  168.     sz$ = UIStartDlg(CUIDLL$, VERPATH, "FDispDlgProc", HELPWELCOME, HELPPROC$)
  169.  
  170.     IF sz$ = "CONTINUE" THEN
  171.     IF IsDirWritable(DESTSYS$) = 0 THEN
  172.         GOSUB BADPATH
  173.         GOTO GETPATHL1
  174.     END IF
  175.     UIPop 1
  176.     ELSEIF sz$ = "REACTIVATE" THEN
  177.     GOTO GETPATHL1
  178.     ELSEIF sz$ = "BACK" THEN
  179.     UIPop 1
  180.     GOTO WELCOME
  181.     ELSE
  182.     GOSUB ASKQUIT
  183.     GOTO GETPATHL1
  184.     END IF
  185.  
  186. COPYFILES:
  187.     CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Win32s", "Setup", "0", cmoOverwrite
  188.  
  189.     '' Indicate Win32s install failure until all files known to be copied.
  190.     ExitCode% = EXITFAILURE
  191.     ERR = 0
  192.     CreateDir DEST32S$, cmoNone
  193.     Install
  194.     UpdateSystemIni
  195.     '' Terminate if unhandled fatal error
  196.     IF ERR <> 0 THEN
  197.     GOTO QUIT
  198.     END IF
  199.  
  200.     CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Win32s", "Setup", "1", cmoOverwrite
  201.     CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Win32s", "Version", szNewVer$, cmoOverwrite
  202.     CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Nls", "AnsiCP", "1252", cmoOverwrite
  203.  
  204.     i% = DoMsgBox("Win32s files successfully installed.", "Microsoft Win32s Setup", MB_OK+MB_TASKMODAL)
  205.     '' Indicate Win32s correctly copied and installed.
  206.     ExitCode% = EXITSUCCESS
  207.  
  208. FREECELL:
  209.     IF WIN32ENABLED% = 1 THEN
  210.     sz$ = UIStartDlg(CUIDLL$, FREECELLINSTNOWIN32S, "FInfoDlgProc",0, "")
  211.     ELSE
  212.     sz$ = UIStartDlg(CUIDLL$, FREECELLINST, "FInfoDlgProc",0, "")
  213.     END IF
  214.     IF sz$ = "CONTINUE" THEN
  215.     UIPop 1
  216.     ELSE
  217.     GOTO QUIT
  218.     END IF
  219.  
  220. GETFREEPATH:
  221.     DESTFREE$ = MID$(DESTSYS$,1,3) + "WIN32APP\FREECELL\"
  222.     SetSymbolValue "EditTextIn", DESTFREE$
  223.     SetSymbolValue "EditFocus", "END"
  224.  
  225. GETFREEPATHL1:
  226.     sz$ = UIStartDlg(CUIDLL$, FREECELLPATH, "FEditDlgProc", HELPFREECELL, HELPPROC$)
  227.  
  228.     IF sz$ = "CONTINUE" THEN
  229.     DESTFREE$ = GetSymbolValue("EditTextOut")
  230.  
  231.     IF MID$(DESTFREE$, LEN(DESTFREE$), 1) <> "\" THEN
  232.         DESTFREE$ = DESTFREE$ + "\"
  233.     END IF
  234.     ''Validate new path.
  235.     IF IsDirWritable(DESTFREE$) = 0 THEN
  236.         GOSUB BADPATH
  237.         GOTO GETFREEPATHL1
  238.     END IF
  239.     UIPop 1
  240.  
  241.     GOTO COPYFREECELL
  242.     ELSEIF sz$ = "REACTIVATE" THEN
  243.     GOTO GETFREEPATHL1
  244.     ELSEIF sz$ = "EXIT" THEN
  245.     UIPop 1
  246.     GOTO QUIT
  247.     END IF
  248.  
  249. COPYFREECELL:
  250.     ClearCopyList
  251.     CreateDir DESTFREE$, cmoNone
  252.  
  253.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  254.  
  255.     ERR = 0
  256.     AddSectionFilesToCopyList "Win32appFreecell", SrcDir$, DESTFREE$
  257.     CopyFilesInCopyList
  258.     '' If error copying FreeCell, not a fatal error. Win32s is already installed.
  259.     IF ERR <> 0 THEN
  260.     ERR = 0
  261.     GOTO QUIT
  262.     END IF
  263.     ERR = 0
  264.  
  265.     IF DoesFileExist( DESTSYS$ + "WIN32S.INI", femExists ) THEN
  266.     CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Freecell", "Setup", "1", cmoOverwrite
  267.     CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Freecell", "Version", szNewVer$, cmoOverwrite
  268.     END IF
  269.  
  270.     ERR = 0
  271.     CreateProgmanGroup "Win32 Applications", "", cmoNone
  272.     ShowProgmanGroup   "Win32 Applications", 1, cmoNone
  273.     CreateProgmanItem  "Win32 Applications", "Freecell", DESTFREE$ + "FREECELL.EXE", "", cmoOverwrite
  274.     '' Only put up success dialog if icon added to group
  275.     IF ERR = 0 THEN
  276.     i% = DoMsgBox("Freecell was successfully installed.", "Freecell Setup", MB_OK+MB_TASKMODAL)
  277.     END IF
  278.     ERR = 0
  279.  
  280. QUIT:
  281.     '' Install error handler for final message box routines
  282.     ON ERROR GOTO ERRQUIT
  283.     IF ERR = 0 THEN
  284.     dlg% = ExitCode%
  285.     ELSEIF ERR = STFQUIT THEN
  286.     dlg% = EXITQUIT
  287.     ExitCode% = EXITQUIT
  288.     ELSE
  289.     dlg% = EXITFAILURE
  290.     ExitCode% = EXITQUIT
  291.     END IF
  292.  
  293. QUITL1:
  294.     IF WIN32ENABLED% = 1 THEN
  295.     UIPop 1
  296.     sz$ = UIStartDlg(CUIDLL$, ERCONTINUE, "FInfo0DlgProc", 0, "")
  297.     UIPop 1
  298.     END
  299.     END IF
  300.  
  301.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  302.     IF sz$ = "REACTIVATE" THEN
  303.     GOTO QUITL1
  304.     END IF
  305.     UIPop 1
  306.  
  307.     IF ExitCode% = EXITSUCCESS THEN
  308.     RebootSystem
  309.     CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Win32s", "Setup", "0", cmoOverwrite
  310.     i% = DoMsgBox("Win32s is not properly configured and Win32s Setup must be run again.", "Unable to Restart Windows", MB_ICONEXCLAMATION+MB_OK+MB_TASKMODAL)
  311.     ENDIF
  312.  
  313.     END
  314.  
  315. '' Fatal error handler for error message routine
  316. ERRQUIT:
  317.     i% = DoMsgBox("Setup sources were corrupted!", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  318.     END
  319.  
  320. '' Bypass run-time errors. Let final dialog box display fatal error message.
  321. ERRNORMAL:
  322.     '' Check if user cancelled setup
  323.     IF ERR = STFQUIT THEN
  324.     GOTO QUIT
  325.     END IF
  326.     RESUME NEXT
  327.  
  328.  
  329. BADPATH:
  330.     sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  331.     IF sz$ = "REACTIVATE" THEN
  332.     GOTO BADPATH
  333.     END IF
  334.     UIPop 1
  335.     RETURN
  336.  
  337.   ASKQUIT:
  338.     sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  339.  
  340.     IF sz$ = "EXIT" THEN
  341.     UIPopAll
  342.     ERROR STFQUIT
  343.     ELSEIF sz$ = "REACTIVATE" THEN
  344.     GOTO ASKQUIT
  345.     ELSE
  346.     UIPop 1
  347.     END IF
  348.     RETURN
  349.  
  350.  
  351.  
  352. '**
  353. '** Purpose:
  354. '**     Builds the copy list and performs all installation operations.
  355. '** Arguments:
  356. '**     none.
  357. '** Returns:
  358. '**     none.
  359. '*************************************************************************
  360. SUB Install STATIC
  361.  
  362.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  363.  
  364.     '' Check if overwrite required.
  365.     IF AlwaysCopy% = 1 THEN
  366.     '' Use file layout sections that specify ALWAYS overwrite files
  367.     AddSectionFilesToCopyList "_WindowsSystem", SrcDir$, DESTSYS$
  368.     AddSectionFilesToCopyList "_WindowsSystemWin32s", SrcDir$, DESTSYS$ + "WIN32S\"
  369.     ELSE
  370.     '' Use file layout sections that specify OLDER file version/time check
  371.     AddSectionFilesToCopyList "WindowsSystem", SrcDir$, DESTSYS$
  372.     AddSectionFilesToCopyList "WindowsSystemWin32s", SrcDir$, DESTSYS$ + "WIN32S\"
  373.     END IF
  374.  
  375.     '' Add obsolete files to be removed
  376.     AddSectionFilesToCopyList "Win32sSystemObsoleteFiles", SrcDir$, DESTSYS$ + "WIN32S\"
  377.  
  378.     SetRestartDir GetWindowsDir()
  379.  
  380.     CopyFilesInCopyList
  381.  
  382. END SUB
  383.  
  384. SUB UpdateSystemIni STATIC
  385.  
  386.     VxDPath$ = DEST32S$ + "W32S.386"
  387.     SystemIniPath$ = GetWindowsDir()
  388.  
  389.     t% = MakeSystemIni(SystemIniPath$, VxdPath$)
  390.  
  391. END SUB
  392.  
  393. SUB RebootSystem STATIC
  394.  
  395. '   Check if any files were locked during install.  If the RestartList
  396. '   is not empty, ExitExecRestart() will restart Windows, cleanup setup
  397. '   files, and copy over locked files before Windows restarts.
  398.     i% = RestartListEmpty()
  399.     IF i% = 0 THEN
  400. '      ExitExecRestart() only returns if applications refuse to be shutdown.
  401. '      Win32s is installed but will not operate until Windows is restarted
  402. '      and the Win32s VxD is loaded.
  403.        i% = ExitExecRestart()
  404.      ELSE
  405. '      If the RestartList list is empty, it is necessary to restart windows
  406. '      directly.  The MSSETUP program creates _MSRSTRT.EXE and _MSSETUP.BAT
  407. '      in the restart directory.  This program should be exec'd to handle
  408. '      proper MSSETUP cleanup (temp files) and restart Windows.
  409.        i% = ExitWindowsExec( GetWindowsDir() + "_MSRSTRT.EXE", "_MSSETUP.BAT" )
  410.      ENDIF
  411.  
  412. END SUB
  413.  
  414.  
  415. '**
  416. '** Purpose:
  417. '**     Appends a file name to the end of a directory path,
  418. '**     inserting a backslash character as needed.
  419. '** Arguments:
  420. '**     szDir$  - full directory path (with optional ending "\")
  421. '**     szFile$ - filename to append to directory
  422. '** Returns:
  423. '**     Resulting fully qualified path name.
  424. '*************************************************************************
  425. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  426.     IF szDir$ = "" THEN
  427.     MakePath = szFile$
  428.     ELSEIF szFile$ = "" THEN
  429.     MakePath = szDir$
  430.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  431.     MakePath = szDir$ + szFile$
  432.     ELSE
  433.     MakePath = szDir$ + "\" + szFile$
  434.     END IF
  435. END FUNCTION
  436.