home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM: Edição Extra 1 / ESPECWIN.ISO / util / netscape / setup.mst < prev    next >
Encoding:
Text File  |  1995-11-16  |  14.2 KB  |  399 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 SUB      CreateMailDir (szNetscapeIni$, szMailDir$)
  44. DECLARE SUB      CreateSecurityDir (szNetscapeIni$, szSecurityDir$)
  45. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  46.  
  47. INIT:
  48.     CUIDLL$ = "mscuistf.dll"            ''Custom user interface dll
  49.     HELPPROC$ = "FHelpDlgProc"          ''Help dialog procedure
  50.  
  51.     SetBitmap CUIDLL$, LOGO
  52.     SetTitle "Netscape Setup"
  53.  
  54.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  55.     IF szInf$ = "" THEN
  56.         szInf$ = GetSymbolValue("STF_CWDDIR") + "SETUP.INF"
  57.     END IF
  58.     ReadInfFile szInf$
  59.  
  60.     ' See if the user is running a version of Win32s less than 1.2
  61.     IF IsBadWin32s() THEN
  62.         szErrText$ = "Version 1.1 of the Netscape Navigator uses OLE 2.02, which is not compatible with this version of Win32s."
  63.         szErrText$ = szErrText + " You must upgrade to Win32s version 1.2 before installing the Netscape Navigator."
  64.         szErrText$ = szErrText + "\nFor more information, please read the Netscape Navigator README.TXT file."
  65.         i% = DoMsgBox(szErrText$, "Netscape Setup", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  66.         END
  67.     END IF
  68.  
  69.     ' If there is an existing Netscape installation then use the current
  70.     ' directory as the default location; otherwise use \NETSCAPE
  71.     DEST$ = GetIniKeyString("WIN.INI", "Netscape", "ini")
  72.     IF DEST$ = "" THEN
  73.         DEST$ = MID$(GetWindowsDir, 1, 1) + ":\NETSCAPE"
  74.     ELSE
  75.         SPLITPATH DEST$, drv$, dir$, filename$, ext$
  76.         DEST$ = drv$ + MID$(dir$, 1, LEN(dir$) - 1)
  77.     END IF
  78.  
  79. WELCOME:
  80.     sz$ = UIStartDlg(CUIDLL$, WELCOME, "FInfoDlgProc", APPHELP, HELPPROC$)
  81.     IF sz$ = "CONTINUE" THEN
  82.         UIPop 1
  83.     ELSE
  84.         GOSUB ASKQUIT
  85.         GOTO WELCOME
  86.     END IF
  87.  
  88. GETPATH:
  89.     SetSymbolValue "EditTextIn", DEST$
  90. GETPATHL1:
  91.     sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FGetPathDlgProc", APPHELP, HELPPROC$)
  92.     DEST$ = GetSymbolValue("EditTextOut")
  93.  
  94.     IF sz$ = "CONTINUE" THEN
  95.         IF IsDirWritable(DEST$) = 0 THEN
  96.             GOSUB BADPATH
  97.             GOTO GETPATHL1
  98.         END IF
  99.         UIPop 1
  100.     ELSEIF sz$ = "REACTIVATE" THEN
  101.         GOTO GETPATHL1
  102.     ELSE
  103.         GOSUB ASKQUIT
  104.         GOTO GETPATH
  105.     END IF
  106.  
  107. CHOOSEGROUP:
  108.     SetSymbolValue "ProgramGroup", "Netscape"
  109. CHOOSEGROUP1:
  110.     sz$ = UIStartDlg(CUIDLL$, PROGROUP, "FProgramGroupDlgProc", APPHELP, HELPPROC$)
  111.  
  112.     IF sz$ = "CONTINUE" THEN
  113.         UIPop 1
  114.     ELSEIF sz$ = "REACTIVATE" THEN
  115.         GOTO CHOOSEGROUP1
  116.     ELSE
  117.         GOSUB ASKQUIT
  118.         GOTO CHOOSEGROUP1
  119.     END IF
  120.  
  121.     Install
  122.  
  123. QUIT:
  124.     ON ERROR GOTO ERRQUIT
  125.  
  126.     IF ERR = 0 THEN
  127.         IF DoMsgBox("Installation is complete. Would you like to read the README file now?", "Netscape Setup", MB_YESNO) = IDYES THEN
  128.             WinExec "NOTEPAD " + MakePath(DEST$, "README.TXT"), SW_SHOW
  129.         END IF
  130.         END
  131.     ELSEIF ERR = STFQUIT THEN
  132.         dlg% = EXITQUIT
  133.     ELSE
  134.         dlg% = EXITFAILURE
  135.     END IF
  136. QUITL1:
  137.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  138.     IF sz$ = "REACTIVATE" THEN
  139.         GOTO QUITL1
  140.     END IF
  141.     UIPop 1
  142.  
  143.     END
  144.  
  145. ERRQUIT:
  146.     i% = DoMsgBox("Setup sources were corrupted!", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  147.     END
  148.  
  149. BADPATH:
  150.     sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  151.     IF sz$ = "REACTIVATE" THEN
  152.         GOTO BADPATH
  153.     END IF
  154.     UIPop 1
  155.     RETURN
  156.  
  157. ASKQUIT:
  158.     sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  159.  
  160.     IF sz$ = "EXIT" THEN
  161.         UIPopAll
  162.         ERROR STFQUIT
  163.     ELSEIF sz$ = "REACTIVATE" THEN
  164.         GOTO ASKQUIT
  165.     ELSE
  166.         UIPop 1
  167.     END IF
  168.     RETURN
  169.  
  170. '**
  171. '** Purpose:
  172. '**     Creates specified news directory
  173. '** Arguments:
  174. '**     Path to Netscape INI file and directory to create.
  175. '** Returns:
  176. '**     none.
  177. '*************************************************************************
  178. SUB CreateNewsDir (szNetscapeIni$, szNewsDir$) STATIC
  179.     ' Check for a file with the same name as the directory we are trying to create
  180.     IF DoesFileExist(szNewsDir$, femExists) THEN
  181.         ' Try using MOZNEWS as the directory name
  182.         IF DoesFileExist(MakePath(DEST$, "MOZNEWS"), fmExists) = 0 THEN
  183.             CreateDir MakePath(DEST$, "MOZNEWS"), cmoNone
  184.  
  185.             ' Add a line to the Netscape INI file pointing to the news directory
  186.             CreateIniKeyValue szNetscapeIni$, "News", "News Directory", MakePath(DEST$, "MOZNEWS"), cmoOverwrite
  187.         END IF
  188.     ELSE
  189.         CreateDir szNewsDir$, cmoNone
  190.  
  191.         ' Add a line to the Netscape INI file pointing to the news directory
  192.         CreateIniKeyValue szNetscapeIni$, "News", "News Directory", szNewsDir$, cmoOverwrite
  193.     END IF
  194. END SUB
  195.  
  196. '**
  197. '** Purpose:
  198. '**     Creates specified mail directory
  199. '** Arguments:
  200. '**     Path to Netscape INI file and directory to create.
  201. '** Returns:
  202. '**     none.
  203. '*************************************************************************
  204. SUB CreateMailDir (szNetscapeIni$, szMailDir$) STATIC
  205.     ' Check for a file with the same name as the directory we are trying to create
  206.     IF DoesFileExist(szMailDir$, femExists) THEN
  207.         ' Try using Mail as the directory name
  208.         IF DoesFileExist(MakePath(DEST$, "Mail"), fmExists) = 0 THEN
  209.             CreateDir MakePath(DEST$, "Mail"), cmoNone
  210.  
  211.             ' Add a line to the Netscape INI file pointing to the mail directory
  212.             CreateIniKeyValue szNetscapeIni$, "Mail", "Mail Directory", MakePath(DEST$, "Mail"), cmoOverwrite
  213.         END IF
  214.     ELSE
  215.         CreateDir szMailDir$, cmoNone
  216.  
  217.         ' Add a line to the Netscape INI file pointing to the mail directory
  218.         CreateIniKeyValue szNetscapeIni$, "Mail", "Mail Directory", szMailDir$, cmoOverwrite
  219.     END IF
  220. END SUB
  221.  
  222. '**
  223. '** Purpose:
  224. '**     Creates specified security directory
  225. '** Arguments:
  226. '**     Path to Netscape INI file and directory to create.
  227. '** Returns:
  228. '**     none.
  229. '*************************************************************************
  230. SUB CreateSecurityDir (szNetscapeIni$, szSecurityDir$) STATIC
  231.     ' Check for a file with the same name as the directory we are trying to create
  232.     IF DoesFileExist(szSecurityDir$, femExists) THEN
  233.         ' Try using Security as the directory name
  234.         IF DoesFileExist(MakePath(DEST$, "Security"), fmExists) = 0 THEN
  235.             CreateDir MakePath(DEST$, "Security"), cmoNone
  236.  
  237.             ' Add a line to the Netscape INI file pointing to the security directory
  238.             CreateIniKeyValue szNetscapeIni$, "Security", "Security Directory", MakePath(DEST$, "Mail"), cmoOverwrite
  239.         END IF
  240.     ELSE
  241.         CreateDir szSecurityDir$, cmoNone
  242.  
  243.         ' Add a line to the Netscape INI file pointing to the security directory
  244.         CreateIniKeyValue szNetscapeIni$, "Security", "Security Directory", szSecurityDir$, cmoOverwrite
  245.     END IF
  246. END SUB
  247.  
  248.  
  249. '**
  250. '** Purpose:
  251. '**     Builds the copy list and performs all installation operations.
  252. '** Arguments:
  253. '**     none.
  254. '** Returns:
  255. '**     none.
  256. '*************************************************************************
  257. SUB Install STATIC
  258.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  259.     ' Create user specified directory and CACHE sub-directory
  260.     CreateDir DEST$, cmoNone
  261.     CreateDir MakePath(DEST$, "CACHE"), cmoNone
  262.  
  263.     AddSectionFilesToCopyList "Files", SrcDir$, DEST$
  264.  
  265.     ' Files needed for OLE2 go in the Windows SYSTEM directory
  266.     AddSectionFilesToCopyList "OLE2", SrcDir$, GetWindowsSysDir
  267.  
  268.     ' If there is an existing NETSCAPE.INI file then ask the user if they
  269.     ' want to overwrite the existing file
  270.     IF DoesFileExist(MakePath(DEST$, "NETSCAPE.INI"), femExists) THEN
  271.         IF DoMsgBox("Do you want to overwrite the existing NETSCAPE.INI file?", "Netscape Setup", MB_YESNO) = IDYES THEN
  272.             AddSectionFilesToCopyList "INI", SrcDir$, DEST$
  273.         END IF
  274.     ELSE
  275.         AddSectionFilesToCopyList "INI", SrcDir$, DEST$
  276.     END IF
  277.  
  278.     CopyFilesInCopyList
  279.  
  280.     ' Merge OLE2 registration into system registry
  281.     WinExec "REGEDIT /S OLE2.REG", SW_SHOW
  282.  
  283.     ' Modify the win.ini file to have a [Netscape] section with a keyname-value
  284.     ' pair for the Netscape INI file location
  285.     CreateIniKeyValue "WIN.INI", "Netscape", "ini", MakePath(DEST$, "NETSCAPE.INI"), cmoOverwrite
  286.  
  287.     szNetscapeIni$ = MakePath(DEST$, "NETSCAPE.INI")
  288.  
  289.     ' If the user specified an installation location other than the default
  290.     ' location, then update the netscape.ini file accordingly
  291.     IF DEST$ <> "C:\NETSCAPE" THEN
  292.         UpdateNetscapeIni szNetscapeIni$
  293.     END IF
  294.  
  295.     ' See if there is a news directory specified in the INI file
  296.     szNewsDir$ = GetIniKeyString(szNetscapeIni$, "News", "News Directory")
  297.     IF szNewsDir$ = "" THEN
  298.         CreateNewsDir szNetscapeIni$, MakePath(DEST$, "NEWS")
  299.     ELSEIF DoesDirExist(szNewsDir$) = 0 THEN
  300.         CreateNewsDir szNetscapeIni$, szNewsDir$
  301.     END IF
  302.  
  303.     ' See if there is a mail directory specified in the INI file
  304.     szMailDir$ = GetIniKeyString(szNetscapeIni$, "Mail", "Mail Directory")
  305.     IF szMailDir$ = "" THEN
  306.         CreateMailDir szNetscapeIni$, MakePath(DEST$, "MAIL")
  307.     ELSEIF DoesDirExist(szMailDir$) = 0 THEN
  308.         CreateMailDir szNetscapeIni$, szMailDir$
  309.     END IF
  310.  
  311.     ' See if there is a security directory specified in the INI file
  312.     szSecurityDir$ = GetIniKeyString(szNetscapeIni$, "Security", "Security Directory")
  313.     IF szSecurityDir$ = "" THEN
  314.         CreateSecurityDir szNetscapeIni$, MakePath(DEST$, "SECURITY")
  315.     ELSEIF DoesDirExist(szSecurityDir$) = 0 THEN
  316.         CreateSecurityDir szNetscapeIni$, szSecurityDir$
  317.     END IF
  318.  
  319.  
  320.     ' Check to see if the NEWSRC file specified in the NETSCAPE.INI actually exists
  321.     szNewsRC$ = GetIniKeyString(szNetscapeIni$, "Main", "News RC")
  322.     IF szNewsRC$ <> "" THEN
  323.         IF DoesFileExist(szNewsRC$, femExists) = 0 THEN
  324.             ' Make the default NEWSRC file be in the NEWS sub-directory
  325.             CreateIniKeyValue szNetscapeIni$, "Main", "News RC", MakePath(DEST$, "NEWS\NEWSRC"), cmoOverwrite
  326.         END IF
  327.     END IF
  328.  
  329.     ' Setup Netscape to use the audio player as an external viewer
  330.     CreateIniKeyValue szNetscapeIni$, "Viewers", "audio/basic", MakePath(DEST$, "NAPLAYER.EXE"), cmoOverwrite
  331.     CreateIniKeyValue szNetscapeIni$, "Viewers", "audio/x-aiff", MakePath(DEST$, "NAPLAYER.EXE"), cmoOverwrite
  332.     CreateIniKeyValue szNetscapeIni$, "Suffixes", "audio/basic", "au,snd", cmoOverwrite
  333.     CreateIniKeyValue szNetscapeIni$, "Suffixes", "audio/x-aiff", "aif,aiff,aifc", cmoOverwrite
  334.  
  335.     ' Make sure that the user doesn't have a home page containing mcom.com
  336.     szHomePage$ = GetIniKeyString(szNetscapeIni$, "Main", "Home Page")
  337.     IF InStr(LCase$(szHomePage$), "mcom.com") THEN
  338.     ' IF szHomePage$ = "http://home.mcom.com/home/welcome.html" THEN
  339.         CreateIniKeyValue szNetscapeIni$, "Main", "Home Page", "http://home.netscape.com/", cmoOverwrite
  340.     END IF
  341.  
  342.     ' If the user doesn't have an existing cookie file, then see if they have an existing
  343.     ' internetMCI cookie file and if they do make a copy of it
  344.     szCookieFile$ = GetIniKeyString(szNetscapeIni$, "Cookies", "Cookie File")
  345.     IF szCookieFile$ = "" THEN
  346.         szCookieFile$ = MakePath(DEST$, "COOKIES.TXT")
  347.     END IF
  348.     IF DoesFileExist(szCookieFile$, femExists) = 0 THEN
  349.         szInternetMCI$ = GetIniKeyString("WIN.INI", "IMCI", "ini")
  350.         IF szInternetMCI$ <> "" THEN
  351.             szMCICookie$ = GetIniKeyString(szInternetMCI$, "Cookies", "Cookie File")
  352.             IF szMCICookie$ <> "" THEN
  353.                 IF DoesFileExist(szMCICookie$, femExists) THEN
  354.                     CopyFile szMCICookie$, szCookieFile$, cmoNone, 0
  355.                 END IF
  356.             END IF
  357.         END IF
  358.     END IF
  359.  
  360.     ' Show the Program Manager
  361.     ShowWindow FindWindow("PROGMAN", NULL), SW_RESTORE
  362.  
  363.     ' Update program group and program items
  364.     Group$ = GetSymbolValue("ProgramGroup")
  365.     CreateProgmanGroup Group$, "", cmoNone
  366.     ShowProgmanGroup  Group$, 1, cmoNone
  367.     SLEEP 1
  368.     CreateProgmanItem Group$, "Netscape", MakePath(DEST$, "NETSCAPE.EXE"), "", cmoOverwrite
  369.     CreateProgmanItem Group$, "NAPlayer", MakePath(DEST$, "NAPLAYER.EXE"), "", cmoOverwrite
  370.  
  371.     ' Only add a README file icon if this is the default program group
  372.     if Group$ = "Netscape" then
  373.         CreateProgmanItem Group$, "Read Me", "notepad "+ MakePath(DEST$, "README.TXT"), "", cmoOverwrite
  374.     end if
  375.     SLEEP 1
  376. END SUB
  377.  
  378. '**
  379. '** Purpose:
  380. '**     Appends a file name to the end of a directory path,
  381. '**     inserting a backslash character as needed.
  382. '** Arguments:
  383. '**     szDir$  - full directory path (with optional ending "\")
  384. '**     szFile$ - filename to append to directory
  385. '** Returns:
  386. '**     Resulting fully qualified path name.
  387. '*************************************************************************
  388. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  389.     IF szDir$ = "" THEN
  390.         MakePath = szFile$
  391.     ELSEIF szFile$ = "" THEN
  392.         MakePath = szDir$
  393.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  394.         MakePath = szDir$ + szFile$
  395.     ELSE
  396.         MakePath = szDir$ + "\" + szFile$
  397.     END IF
  398. END FUNCTION
  399.