RetroZilla/xpinstall/packager/build/win/gre/XPI_JSTs/gre.jst

165 lines
4.4 KiB
Plaintext
Raw Normal View History

2015-10-21 05:03:22 +02:00
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);
subkey = regRootKey + "\\$UserAgent$";
err = winreg.setValueString(subkey, "Version", "$UserAgent$");
tmpstr = new String(fProgram);
err = winreg.setValueString(subkey, "GreHome", tmpstr.substring(0, tmpstr.length-1));
err = winreg.setValueString(subkey, "GreComponentsDir", fProgram + "Components");
registerMainKeys(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 valname; //the name of the value you want to look at
var value; //the data in the value you want to look at.
var err;
var fWindows;
fWindows = getFolder("Windows");
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, "UninstallString", fWindows + "$UninstallFile$ /ua \"$UserAgentShort$\"");
err = winreg.setValueString(subkey, "Description", "$ProductName$ ($UserAgentShort$)");
}
// main
var srDest;
var err;
var err2;
var fProgram;
var fWindowsSystem;
var fileComponentRegStr;
var fileComponentReg;
var restrictedAccess;
var fileToRegister;
var regRootKey;
// So far the only argument passed in is the root path into the Windows registry.
regRootKey = new String(Install.arguments);
srDest = $SpaceRequired$:bin;
err = initInstall("$ProductName$", "GRE", "$Version$");
logComment("initInstall: " + err);
fProgram = getFolder("Program");
logComment("fProgram: " + fProgram);
if(verifyDiskSpace(fProgram, srDest))
{
setPackageFolder(fProgram);
err = addDirectory("",
"",
"gre", // 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);
// Let the uninstaller know about this generated file.
logComment("Installing: " + fProgram + ".autoreg");
// check return value
if( err == SUCCESS )
{
registerKeys();
// // 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