function IsWinnt() { /* Determines if the script is running under NT or not. * */ var winreg = getWinRegistry(); var subkey; var valname; var szCurrentVersion; winreg.setRootKey(winreg.HKEY_LOCAL_MACHINE); subkey = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"; valname = "CurrentVersion"; szCurrentVersion = winreg.getValueString(subkey, valname); logComment("szCurrentVersion: " + szCurrentVersion); if((szCurrentVersion == "") || (szCurrentVersion == null)) { return false; } else { return true; } } function registerKeys() { var subkey; //the name of the subkey you are poking around in var err; var winreg; var tmpstr; winreg = getWinRegistry(); winreg.setRootKey(winreg.HKEY_LOCAL_MACHINE); createRootRegKey(winreg); registerMainKeys(winreg); registerMozillaKeys(winreg); } function createRootRegKey(winreg) { var subkey; var tmpstr; var tmpstr2; var index; tmpstr = new String(regRootKey); index = tmpstr.indexOf("\\"); subkey = ""; while(index > 0) { subkey = subkey + tmpstr.substring(0, index); winreg.createKey(subkey,""); tmpstr2 = tmpstr.substring(index+1, tmpstr.length); tmpstr = new String(tmpstr2); index = tmpstr.indexOf("\\"); subkey = subkey + "\\"; } if(tmpstr.length > 0) { subkey = subkey + tmpstr; logComment("subkey: " + subkey); winreg.createKey(subkey,""); } winreg.createKey(subkey + "\\$UserAgent$",""); } function registerMainKeys(winreg) { var subkey; //the name of the subkey you are poking around in var err; err = winreg.setValueString(regRootKey, "CurrentVersion", "$UserAgent$"); winreg.createKey(regRootKey + "\\$UserAgent$", ""); subkey = regRootKey + "\\$UserAgent$\\Main"; winreg.createKey(subkey,""); err = winreg.setValueString(subkey, "Install Directory", fProgram); subkey = regRootKey + "\\$UserAgent$\\Uninstall"; winreg.createKey(subkey,""); err = winreg.setValueString(subkey, "Uninstall Log Folder", fProgram + "Uninstall"); err = winreg.setValueString(subkey, "Description", "$ProductName$ ($UserAgentShort$)"); } function registerMozillaKeys(winreg) { var regKey; var subkey; //the name of the subkey you are poking around in var err; regKey = "Software\\Mozilla"; winreg.createKey(regKey, ""); winreg.createKey(regKey + "\\MfcEmbed $UserAgent$", ""); subkey = regKey + "\\MfcEmbed $UserAgent$\\bin"; winreg.createKey(subkey, ""); err = winreg.setValueString(subkey, "PathToExe", fProgram + "$MainExeFile$"); subkey = regKey + "\\MfcEmbed $UserAgent$\\Extensions"; winreg.createKey(subkey, ""); err = winreg.setValueString(subkey, "Components", fProgram + "\\Components"); err = winreg.setValueString(subkey, "Plugins", fProgram + "\\Plugins"); } function LogGreUninstaller() { var winreg = getWinRegistry(); var subkey; var valname; var szUninstallString; winreg.setRootKey(winreg.HKEY_LOCAL_MACHINE); subkey = "SOFTWARE\\mozilla.org\Gre\\1.3a\\Uninstall"; valname = "UninstallString"; szUninstallString = winreg.getValueString(subkey, valname); logComment("szUninstall String: " + szUninstallString); // Log the uninstall command to run the GRE uninstaller. // This needs to be logged after all the files have been installed. logComment("Uninstall Command: \"" + szUninstallString + " /app mfcembed /us"); if((szUninstallString == "") || (szUinstallString == null)) { return false; } else { return true; } } // main var srDest; var err; var err2; var fProgram; var fSubdir; var fWindowsSystem; var fileComponentRegStr; var fileComponentReg; var restrictedAccess; var fileToRegister; var regRootKey; regRootKey = new String("Software\\$CompanyName$\\MFCEmbed"); srDest = $SpaceRequired$:bin; err = initInstall("$ProductName$", "MFCEmbed", "$Version$"); logComment("initInstall: " + err); fProgram = getFolder("Program"); logComment("fProgram: " + fProgram); if(verifyDiskSpace(fProgram, srDest)) { setPackageFolder(fProgram); err = addDirectory("", "", "gre_app_support", // dir name in jar to extract fProgram, // Where to put this file (Returned from GetFolder) "", // subdir name to create relative to fProgram true); // Force Flag logComment("addDirectory() of Program returned: " + err); err = addDirectory("", "", "Embed", // dir name in jar to extract fProgram, // Where to put this file (Returned from GetFolder) "", // subdir name to create relative to fProgram true); // Force Flag logComment("addDirectory() of Program returned: " + err); fSubdir = getFolder("Program", "plugins"); File.dirCreate(fSubdir); fSubdir = getFolder("Program", "components"); File.dirCreate(fSubdir); // check return value if( err == SUCCESS ) { registerKeys(); LogGreUninstaller(); // // we don't want to fail on errors for the above // resetError(); err = performInstall(); logComment("performInstall() returned: " + err); } else cancelInstall(err); } else cancelInstall(INSUFFICIENT_DISK_SPACE); // end main