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