home *** CD-ROM | disk | FTP | other *** search
/ Inside Multimedia 1995 August / IMM0895.BIN / magazin / html / netscape / setup.mst < prev    next >
Text File  |  1995-03-30  |  11KB  |  326 lines

  1. '**************************************************************************
  2. '*                              Netscape Setup
  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 PROGROUP      = 260
  14. CONST DESTPATH      = 300
  15. CONST EXITFAILURE   = 400
  16. CONST EXITQUIT      = 600
  17. CONST EXITSUCCESS   = 700
  18. CONST OPTIONS       = 800
  19. CONST APPHELP       = 900
  20. CONST BADPATH       = 6400
  21.  
  22. ''Bitmap ID
  23. CONST LOGO = 1
  24.  
  25. GLOBAL DEST$        ''Default destination directory.
  26.  
  27. CONST SW_MINIMIZE   = 6
  28. CONST SW_RESTORE    = 9
  29. CONST SW_SHOW       = 5
  30.  
  31. CONST IDYES         = 6
  32.  
  33. DECLARE FUNCTION FindWindow LIB "user" (szClassName$, szWindow$) AS INTEGER
  34. DECLARE SUB      ShowWindow LIB "user" (hwnd%, nCmdShow%)
  35. DECLARE SUB      WinExec LIB "kernel" (szCmdLine$, nCmdShow%)
  36.  
  37. DECLARE SUB      UpdateNetscapeIni LIB "mscuistf.dll" (szIniPath$)
  38.  
  39. DECLARE FUNCTION IsBadWin32s LIB "mscuistf.dll" () AS INTEGER
  40.  
  41. DECLARE SUB      Install
  42. DECLARE SUB      CreateNewsDir (szNetscapeIni$, szNewsDir$)
  43. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  44.  
  45. INIT:
  46.     CUIDLL$ = "mscuistf.dll"            ''Custom user interface dll
  47.     HELPPROC$ = "FHelpDlgProc"          ''Help dialog procedure
  48.  
  49.     SetBitmap CUIDLL$, LOGO
  50.     SetTitle "Netscape Setup"
  51.  
  52.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  53.     IF szInf$ = "" THEN
  54.         szInf$ = GetSymbolValue("STF_CWDDIR") + "SETUP.INF"
  55.     END IF
  56.     ReadInfFile szInf$
  57.  
  58.     ' See if the user is running a version of Win32s less than 1.2
  59.     IF IsBadWin32s() THEN
  60.         szErrText$ = "Version 1.1 of the Netscape Navigator uses OLE 2.02, which is not compatible with this version of Win32s."
  61.         szErrText$ = szErrText + " You must upgrade to Win32s version 1.2 before installing the Netscape Navigator."
  62.         szErrText$ = szErrText + "\nFor more information, please read the Netscape Navigator README.TXT file."
  63.         i% = DoMsgBox(szErrText$, "Netscape Setup", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  64.         END
  65.     END IF
  66.  
  67.     ' If there is an existing Netscape installation then use the current
  68.     ' directory as the default location; otherwise use \NETSCAPE
  69.     DEST$ = GetIniKeyString("WIN.INI", "Netscape", "ini")
  70.     IF DEST$ = "" THEN
  71.         DEST$ = MID$(GetWindowsDir, 1, 1) + ":\NETSCAPE"
  72.     ELSE
  73.         SPLITPATH DEST$, drv$, dir$, filename$, ext$
  74.         DEST$ = drv$ + MID$(dir$, 1, LEN(dir$) - 1)
  75.     END IF
  76.  
  77. WELCOME:
  78.     sz$ = UIStartDlg(CUIDLL$, WELCOME, "FInfoDlgProc", APPHELP, HELPPROC$)
  79.     IF sz$ = "CONTINUE" THEN
  80.         UIPop 1
  81.     ELSE
  82.         GOSUB ASKQUIT
  83.         GOTO WELCOME
  84.     END IF
  85.  
  86. GETPATH:
  87.     SetSymbolValue "EditTextIn", DEST$
  88. GETPATHL1:
  89.     sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FGetPathDlgProc", APPHELP, HELPPROC$)
  90.     DEST$ = GetSymbolValue("EditTextOut")
  91.  
  92.     IF sz$ = "CONTINUE" THEN
  93.         IF IsDirWritable(DEST$) = 0 THEN
  94.             GOSUB BADPATH
  95.             GOTO GETPATHL1
  96.         END IF
  97.         UIPop 1
  98.     ELSEIF sz$ = "REACTIVATE" THEN
  99.         GOTO GETPATHL1
  100.     ELSE
  101.         GOSUB ASKQUIT
  102.         GOTO GETPATH
  103.     END IF
  104.  
  105. CHOOSEGROUP:
  106.     SetSymbolValue "ProgramGroup", "Netscape"
  107. CHOOSEGROUP1:
  108.     sz$ = UIStartDlg(CUIDLL$, PROGROUP, "FProgramGroupDlgProc", APPHELP, HELPPROC$)
  109.  
  110.     IF sz$ = "CONTINUE" THEN
  111.         UIPop 1
  112.     ELSEIF sz$ = "REACTIVATE" THEN
  113.         GOTO CHOOSEGROUP1
  114.     ELSE
  115.         GOSUB ASKQUIT
  116.         GOTO CHOOSEGROUP1
  117.     END IF
  118.  
  119.     Install
  120.  
  121. QUIT:
  122.     ON ERROR GOTO ERRQUIT
  123.  
  124.     IF ERR = 0 THEN
  125.         IF DoMsgBox("Installation is complete. Would you like to read the README file now?", "Netscape Setup", MB_YESNO) = IDYES THEN
  126.             WinExec "NOTEPAD " + MakePath(DEST$, "README.TXT"), SW_SHOW
  127.         END IF
  128.         END
  129.     ELSEIF ERR = STFQUIT THEN
  130.         dlg% = EXITQUIT
  131.     ELSE
  132.         dlg% = EXITFAILURE
  133.     END IF
  134. QUITL1:
  135.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  136.     IF sz$ = "REACTIVATE" THEN
  137.         GOTO QUITL1
  138.     END IF
  139.     UIPop 1
  140.  
  141.     END
  142.  
  143. ERRQUIT:
  144.     i% = DoMsgBox("Setup sources were corrupted!", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  145.     END
  146.  
  147. BADPATH:
  148.     sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  149.     IF sz$ = "REACTIVATE" THEN
  150.         GOTO BADPATH
  151.     END IF
  152.     UIPop 1
  153.     RETURN
  154.  
  155. ASKQUIT:
  156.     sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  157.  
  158.     IF sz$ = "EXIT" THEN
  159.         UIPopAll
  160.         ERROR STFQUIT
  161.     ELSEIF sz$ = "REACTIVATE" THEN
  162.         GOTO ASKQUIT
  163.     ELSE
  164.         UIPop 1
  165.     END IF
  166.     RETURN
  167.  
  168. '**
  169. '** Purpose:
  170. '**     Creates specified news directory
  171. '** Arguments:
  172. '**     Path to Netscape INI file and directory to create.
  173. '** Returns:
  174. '**     none.
  175. '*************************************************************************
  176. SUB CreateNewsDir (szNetscapeIni$, szNewsDir$) STATIC
  177.     ' Check for a file with the same name as the directory we are trying to create
  178.     IF DoesFileExist(szNewsDir$, femExists) THEN
  179.         ' Try using MOZNEWS as the directory name
  180.         IF DoesFileExist(MakePath(DEST$, "MOZNEWS"), fmExists) = 0 THEN
  181.             CreateDir MakePath(DEST$, "MOZNEWS"), cmoNone
  182.  
  183.             ' Add a line to the Netscape INI file pointing to the news directory
  184.             CreateIniKeyValue szNetscapeIni$, "News", "News Directory", MakePath(DEST$, "MOZNEWS"), cmoOverwrite
  185.         END IF
  186.     ELSE
  187.         CreateDir szNewsDir$, cmoNone
  188.  
  189.         ' Add a line to the Netscape INI file pointing to the news directory
  190.         CreateIniKeyValue szNetscapeIni$, "News", "News Directory", szNewsDir$, cmoOverwrite
  191.     END IF
  192. END SUB
  193.  
  194. '**
  195. '** Purpose:
  196. '**     Builds the copy list and performs all installation operations.
  197. '** Arguments:
  198. '**     none.
  199. '** Returns:
  200. '**     none.
  201. '*************************************************************************
  202. SUB Install STATIC
  203.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  204.     ' Create user specified directory and CACHE sub-directory
  205.     CreateDir DEST$, cmoNone
  206.     CreateDir MakePath(DEST$, "CACHE"), cmoNone
  207.  
  208.     AddSectionFilesToCopyList "Files", SrcDir$, DEST$
  209.  
  210.     ' Files needed for OLE2 go in the Windows SYSTEM directory
  211.     AddSectionFilesToCopyList "OLE2", SrcDir$, GetWindowsSysDir
  212.  
  213.     ' If there is an existing NETSCAPE.INI file then ask the user if they
  214.     ' want to overwrite the existing file
  215.     IF DoesFileExist(MakePath(DEST$, "NETSCAPE.INI"), femExists) THEN
  216.         IF DoMsgBox("Do you want to overwrite the existing NETSCAPE.INI file?", "Netscape Setup", MB_YESNO) = IDYES THEN
  217.             AddSectionFilesToCopyList "INI", SrcDir$, DEST$
  218.         END IF
  219.     ELSE
  220.         AddSectionFilesToCopyList "INI", SrcDir$, DEST$
  221.     END IF
  222.  
  223.     CopyFilesInCopyList
  224.  
  225.     ' Merge OLE2 registration into system registry
  226.     WinExec "REGEDIT /S OLE2.REG", SW_SHOW
  227.  
  228.     ' Modify the win.ini file to have a [Netscape] section with a keyname-value
  229.     ' pair for the Netscape INI file location
  230.     CreateIniKeyValue "WIN.INI", "Netscape", "ini", MakePath(DEST$, "NETSCAPE.INI"), cmoOverwrite
  231.  
  232.     szNetscapeIni$ = MakePath(DEST$, "NETSCAPE.INI")
  233.  
  234.     ' If the user specified an installation location other than the default
  235.     ' location, then update the netscape.ini file accordingly
  236.     IF DEST$ <> "C:\NETSCAPE" THEN
  237.         UpdateNetscapeIni szNetscapeIni$
  238.     END IF
  239.  
  240.     ' See if there is a news directory specified in the INI file
  241.     szNewsDir$ = GetIniKeyString(szNetscapeIni$, "News", "News Directory")
  242.     IF szNewsDir$ = "" THEN
  243.         CreateNewsDir szNetscapeIni$, MakePath(DEST$, "NEWS")
  244.     ELSEIF DoesDirExist(szNewsDir$) = 0 THEN
  245.         CreateNewsDir szNetscapeIni$, szNewsDir$
  246.     END IF
  247.  
  248.     ' Check to see if the NEWSRC file specified in the NETSCAPE.INI actually exists
  249.     szNewsRC$ = GetIniKeyString(szNetscapeIni$, "Main", "News RC")
  250.     IF szNewsRC$ <> "" THEN
  251.         IF DoesFileExist(szNewsRC$, femExists) = 0 THEN
  252.             ' Make the default NEWSRC file be in the NEWS sub-directory
  253.             CreateIniKeyValue szNetscapeIni$, "Main", "News RC", MakePath(DEST$, "NEWS\NEWSRC"), cmoOverwrite
  254.         END IF
  255.     END IF
  256.  
  257.     ' Setup Netscape to use the audio player as an external viewer
  258.     CreateIniKeyValue szNetscapeIni$, "Viewers", "audio/basic", MakePath(DEST$, "NAPLAYER.EXE"), cmoOverwrite
  259.     CreateIniKeyValue szNetscapeIni$, "Viewers", "audio/x-aiff", MakePath(DEST$, "NAPLAYER.EXE"), cmoOverwrite
  260.     CreateIniKeyValue szNetscapeIni$, "Suffixes", "audio/basic", "au,snd", cmoOverwrite
  261.     CreateIniKeyValue szNetscapeIni$, "Suffixes", "audio/x-aiff", "aif,aiff,aifc", cmoOverwrite
  262.  
  263.     ' Make sure that the user doesn't have a home page containing mcom.com
  264.     szHomePage$ = GetIniKeyString(szNetscapeIni$, "Main", "Home Page")
  265.     IF InStr(LCase$(szHomePage$), "mcom.com") THEN
  266.     ' IF szHomePage$ = "http://home.mcom.com/home/welcome.html" THEN
  267.         CreateIniKeyValue szNetscapeIni$, "Main", "Home Page", "http://home.netscape.com/", cmoOverwrite
  268.     END IF
  269.  
  270.     ' If the user doesn't have an existing cookie file, then see if they have an existing
  271.     ' internetMCI cookie file and if they do make a copy of it
  272.     szCookieFile$ = GetIniKeyString(szNetscapeIni$, "Cookies", "Cookie File")
  273.     IF szCookieFile$ = "" THEN
  274.         szCookieFile$ = MakePath(DEST$, "COOKIES.TXT")
  275.     END IF
  276.     IF DoesFileExist(szCookieFile$, femExists) = 0 THEN
  277.         szInternetMCI$ = GetIniKeyString("WIN.INI", "IMCI", "ini")
  278.         IF szInternetMCI$ <> "" THEN
  279.             szMCICookie$ = GetIniKeyString(szInternetMCI$, "Cookies", "Cookie File")
  280.             IF szMCICookie$ <> "" THEN
  281.                 IF DoesFileExist(szMCICookie$, femExists) THEN
  282.                     CopyFile szMCICookie$, szCookieFile$, cmoNone, 0
  283.                 END IF
  284.             END IF
  285.         END IF
  286.     END IF
  287.  
  288.     ' Show the Program Manager
  289.     ShowWindow FindWindow("PROGMAN", NULL), SW_RESTORE
  290.  
  291.     ' Update program group and program items
  292.     Group$ = GetSymbolValue("ProgramGroup")
  293.     CreateProgmanGroup Group$, "", cmoNone
  294.     ShowProgmanGroup  Group$, 1, cmoNone
  295.     SLEEP 1
  296.     CreateProgmanItem Group$, "Netscape", MakePath(DEST$, "NETSCAPE.EXE"), "", cmoOverwrite
  297.  
  298.     ' Only add a README file icon if this is the default program group
  299.     if Group$ = "Netscape" then
  300.         CreateProgmanItem Group$, "Read Me", "notepad "+ MakePath(DEST$, "README.TXT"), "", cmoOverwrite
  301.     end if
  302.     SLEEP 1
  303. END SUB
  304.  
  305. '**
  306. '** Purpose:
  307. '**     Appends a file name to the end of a directory path,
  308. '**     inserting a backslash character as needed.
  309. '** Arguments:
  310. '**     szDir$  - full directory path (with optional ending "\")
  311. '**     szFile$ - filename to append to directory
  312. '** Returns:
  313. '**     Resulting fully qualified path name.
  314. '*************************************************************************
  315. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  316.     IF szDir$ = "" THEN
  317.         MakePath = szFile$
  318.     ELSEIF szFile$ = "" THEN
  319.         MakePath = szDir$
  320.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  321.         MakePath = szDir$ + szFile$
  322.     ELSE
  323.         MakePath = szDir$ + "\" + szFile$
  324.     END IF
  325. END FUNCTION
  326.