зеркало из https://github.com/mozilla/pjs.git
244 строки
8.5 KiB
Plaintext
244 строки
8.5 KiB
Plaintext
function createShortcuts()
|
|
{
|
|
var subkey;
|
|
var valname;
|
|
var szStartMenuPrograms;
|
|
var szStartMenu;
|
|
var szFolderDesktop;
|
|
var szFolderQuickLaunch;
|
|
var szFolderSendTo;
|
|
var winreg;
|
|
var fWindows;
|
|
var fTemp;
|
|
var fCommunicator;
|
|
var fileExe;
|
|
var scExeDesc;
|
|
var scProfileDesc;
|
|
var scProfileDescParam;
|
|
var scFolderName;
|
|
var fFolderDesktop;
|
|
var fFolderPath;
|
|
var fFolderPathStr;
|
|
var is_winnt;
|
|
var szCurrentVersion;
|
|
|
|
winreg = getWinRegistry();
|
|
fWindows = getFolder("Windows");
|
|
fCommunicator = getFolder("Communicator");
|
|
fTemp = fCommunicator + "$MainExeFile$";
|
|
fileExe = getFolder("file:///", fTemp);
|
|
scExeDesc = "$ProductName$";
|
|
scProfileDesc = "Profile Manager";
|
|
scProfileDescParam = "-ProfileManager";
|
|
scFolderName = "$ProductName$";
|
|
if(winreg != null)
|
|
{
|
|
/* determine if the script is running under NT or not */
|
|
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))
|
|
{
|
|
is_winnt = false;
|
|
}
|
|
else
|
|
{
|
|
is_winnt = true;
|
|
}
|
|
|
|
if(is_winnt == false)
|
|
{
|
|
logComment("is_winnt is false: " + is_winnt);
|
|
|
|
winreg.setRootKey(winreg.HKEY_CURRENT_USER);
|
|
subkey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders";
|
|
valname = "Programs";
|
|
szStartMenuPrograms = winreg.getValueString(subkey, valname);
|
|
valname = "Start Menu";
|
|
szStartMenu = winreg.getValueString(subkey, valname);
|
|
valname = "Desktop";
|
|
szFolderDesktop = winreg.getValueString(subkey, valname);
|
|
}
|
|
else
|
|
{
|
|
logComment("is_winnt is true: " + is_winnt);
|
|
|
|
winreg.setRootKey(winreg.HKEY_LOCAL_MACHINE);
|
|
subkey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders";
|
|
valname = "Common Programs";
|
|
szStartMenuPrograms = winreg.getValueString(subkey, valname);
|
|
valname = "Common Start Menu";
|
|
szStartMenu = winreg.getValueString(subkey, valname);
|
|
valname = "Common Desktop";
|
|
szFolderDesktop = winreg.getValueString(subkey, valname);
|
|
}
|
|
|
|
winreg.setRootKey(winreg.HKEY_CURRENT_USER);
|
|
subkey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders";
|
|
valname = "SendTo";
|
|
szFolderSendTo = winreg.getValueString(subkey, valname);
|
|
|
|
subkey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\GrpConv\\MapGroups";
|
|
valname = "Quick Launch";
|
|
szFolderQuickLaunch = winreg.getValueString(subkey, valname);
|
|
|
|
winreg.setRootKey(winreg.HKEY_LOCAL_MACHINE);
|
|
subkey = "SOFTWARE\\$CompanyName$\\$ProductName$\\$UserAgent$\\Main";
|
|
valname = "Program Folder Path";
|
|
fFolderPathStr = winreg.getValueString(subkey, valname);
|
|
if((fFolderPathStr == "") || (fFolderPathStr == null))
|
|
{
|
|
fTemp = szStartMenuPrograms + "\\" + scFolderName;
|
|
fFolderPath = getFolder("file:///", fTemp);
|
|
}
|
|
else
|
|
{
|
|
/* convert the path string to a path folder object */
|
|
fFolderPath = getFolder("file:///", fFolderPathStr);
|
|
}
|
|
/* convert the path string to a path folder object */
|
|
fFolderDesktop = getFolder("file:///", szFolderDesktop);
|
|
|
|
logComment("Folder StartMenuPrograms: " + szStartMenuPrograms);
|
|
logComment("Folder StartMenu : " + szStartMenu);
|
|
logComment("Folder FolderDesktop : " + szFolderDesktop);
|
|
logComment("Folder FolderSendTo : " + szFolderSendTo);
|
|
logComment("Folder FolderQuickLaunch: " + szFolderQuickLaunch);
|
|
logComment("fileExe : " + fileExe);
|
|
logComment("fFolderPath : " + fFolderPath);
|
|
logComment("scExeDesc : " + scExeDesc);
|
|
logComment("fCommunicator : " + fCommunicator);
|
|
|
|
/* explicitly create the fFolderPath even though the windowsShortcut function creates the folder.
|
|
* This is so that the folder creation gets logged for uninstall to remove it. */
|
|
File.dirCreate(fFolderPath);
|
|
|
|
/* create the shortcuts */
|
|
File.windowsShortcut(fileExe, fFolderDesktop, scExeDesc, fCommunicator, "", fileExe, 0);
|
|
File.windowsShortcut(fileExe, fFolderPath, scExeDesc, fCommunicator, "", fileExe, 0);
|
|
File.windowsShortcut(fileExe, fFolderPath, scProfileDesc, fCommunicator, scProfileDescParam, fileExe, 0);
|
|
// File.windowsShortcut(fileExe, fFolderPath, "Test Http", "", "", "http://sweetlou/products/client/temp/ssu", 0);
|
|
|
|
/* set the Program Folder Path in the Mozilla key in the Windows Registry */
|
|
winreg.setRootKey(winreg.HKEY_LOCAL_MACHINE);
|
|
subkey = "SOFTWARE\\$CompanyName$";
|
|
winreg.createKey(subkey,"");
|
|
|
|
valname = "CurrentVersion";
|
|
subkey = "SOFTWARE\\$CompanyName$\\$ProductName$";
|
|
winreg.createKey(subkey,"");
|
|
|
|
valname = "CurrentVersion";
|
|
value = "$UserAgent$";
|
|
err = winreg.setValueString(subkey, valname, value);
|
|
|
|
subkey = "SOFTWARE\\$CompanyName$\\$ProductName$\\$UserAgent$";
|
|
winreg.createKey(subkey,"");
|
|
|
|
subkey = "SOFTWARE\\$CompanyName$\\$ProductName$\\$UserAgent$\\Main";
|
|
winreg.createKey(subkey,"");
|
|
|
|
valname = "Program Folder Path";
|
|
value = fFolderPath;
|
|
err = winreg.setValueString(subkey, valname, value);
|
|
|
|
}
|
|
else
|
|
{
|
|
logComment("winreg is null");
|
|
}
|
|
}
|
|
|
|
function updateWinReg()
|
|
{
|
|
//Notes:
|
|
// can't use a double backslash before subkey - Windows already puts it in.
|
|
// subkeys have to exist before values can be put in.
|
|
var winreg = getWinRegistry();
|
|
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.
|
|
|
|
if(winreg != null)
|
|
{
|
|
winreg.setRootKey(winreg.HKEY_LOCAL_MACHINE);
|
|
subkey = "SOFTWARE\\$CompanyName$";
|
|
winreg.createKey(subkey,"");
|
|
|
|
subkey = "SOFTWARE\\$CompanyName$\\$ProductName$";
|
|
winreg.createKey(subkey,"");
|
|
|
|
valname = "CurrentVersion";
|
|
value = "$UserAgent$";
|
|
err = winreg.setValueString(subkey, valname, value);
|
|
|
|
subkey = "SOFTWARE\\$CompanyName$\\$ProductName$\\$UserAgent$";
|
|
winreg.createKey(subkey,"");
|
|
|
|
subkey = "SOFTWARE\\$CompanyName$\\$ProductName$\\$UserAgent$\\Main";
|
|
winreg.createKey(subkey,"");
|
|
|
|
valname = "Install Directory";
|
|
value = fCommunicator;
|
|
err = winreg.setValueString(subkey, valname, value);
|
|
|
|
// set the App Paths key here
|
|
subkey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\$MainExeFile$";
|
|
winreg.createKey(subkey,"");
|
|
valname = "";
|
|
value = fCommunicator + "$MainExeFile$";
|
|
err = winreg.setValueString(subkey, valname, value);
|
|
|
|
valname = "Path";
|
|
value = fCommunicator;
|
|
err = winreg.setValueString(subkey, valname, value);
|
|
}
|
|
}
|
|
|
|
// main
|
|
var srDest;
|
|
var err;
|
|
var fCommunicator;
|
|
var fWindowsSystem;
|
|
var fileComponentRegStr;
|
|
var fileComponentReg;
|
|
|
|
srDest = $SpaceRequired$:bin;
|
|
err = startInstall("$ProductName$", "Browser", "$Version$");
|
|
logComment("startInstall: " + err);
|
|
|
|
fCommunicator = getFolder("Communicator");
|
|
fWindowsSystem = getFolder("Win System");
|
|
logComment("fCommunicator: " + fCommunicator);
|
|
|
|
if(verifyDiskSpace(fCommunicator, srDest) == true)
|
|
{
|
|
setPackageFolder(fCommunicator);
|
|
err = addDirectory("",
|
|
"$Version$",
|
|
"bin", // dir name in jar to extract
|
|
fCommunicator, // Where to put this file (Returned from GetFolder)
|
|
"", // subdir name to create relative to fCommunicator
|
|
true); // Force Flag
|
|
logComment("addDirectory() of Program returned: " + err);
|
|
|
|
// check return value
|
|
if(!checkError(err))
|
|
{
|
|
fileComponentRegStr = fCommunicator + "component.reg";
|
|
fileComponentReg = getFolder("file:///", fileComponentRegStr);
|
|
err = fileDelete(fileComponentReg);
|
|
logComment("fileDelete() returned: " + err);
|
|
|
|
updateWinReg();
|
|
createShortcuts();
|
|
|
|
err = finalizeInstall();
|
|
logComment("finalizeInstall() returned: " + err);
|
|
}
|
|
}
|
|
|
|
// end main
|