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