home *** CD-ROM | disk | FTP | other *** search
- /*
-
- Set Auto Logon
- And set a RunOnce for when desktop loaded clear auto logon for sure
-
- */
-
- //
- // Date Last Modified: Saturday, October 28, 2006
- //
- // Modified By: Mark Ritter, DjΘ, Michael Mims (zorphnog)
- //
-
-
- function checkInstall(arg)
- {
- position="installer.js";
- whatfunc="checkInstall()";
-
- // 'install' and 'timer' also available
- if (arg !='exit' || ReallyForce)
- {
- if (arg=='exit')
- {
- alert(getText(msgStartInstall));
- remChecks();
- }
-
- InstallPrograms();
- }
- else
- ExitWPI();
-
- if (arg=='exit' && ReallyForce)
- ExitWPI();
-
- if (ReOpenAfterInstall)
- {
- strFile=wpipath+"\\WPI.hta";
- document.location="file:///"+strFile.replace(/\\/g, '/');
-
- return;
- }
- else
- ExitWPI();
- }
-
-
- function ShowInstaller()
- {
- position="installer.js";
- whatfunc="ShowInstaller()";
-
- var iWidth, iHeight;
- iWidth=328+ExtraWidth;
- iHeight=451+ExtraHeight; // 451 with Abort gadget
- if (PlayAudioInInstaller)
- iHeight +=62;
-
- strFile=wpipath+"\\Common\\Installer.hta";
- if (!FileExists(strFile))
- {
- alert(getText(errCouldNotOpenFile)+" '"+strFile+"'.");
- ExitWPI();
- }
-
- //Those lines are better placed here than in the InstallPrograms() function
- if (!ResumeInstall)
- {
- htm(); // Turn off tips
- topLine=0;
- }
- else
- topLine=LastTopLine;
- currentLine=0;
- totalLine = programs.length;
- centerLine = Math.round(maxLines/2);
- maxLines = Math.min(maxLines, totalLine);
-
- window.resizeTo(0,0);
- ResumeInstall==false ? document.location="file:///"+strFile.replace(/\\/g, '/') : null; //change its content
- window.moveTo(25,25); //move it
- window.resizeTo(iWidth,iHeight); //resize it
-
- while (window.document.readyState != 'complete' && !ResumeInstall)
- Pause(0,100); //wait for the new document to be fully loaded
- document.getElementById("InstallHeaderText").innerHTML=getText(InstallerHeaderTxt);
- document.getElementById("Abort").value = getText(btnAbort);
- document.getElementById("Aborted").value = getText(btnAborted);
- document.getElementById("AbortMessage").value = getText(txtAbortMessage);
- document.getElementById("Pause").value = getText(btnPause);
- document.getElementById("Paused").value = getText(btnResume);
- document.getElementById("installLayer").style.cursor='wait';
-
- try
- {
- WshShell.regWrite("HKEY_CURRENT_USER\\Software\\WPI\\ResumeInstall",1,"REG_DWORD"); // Set install state to in progress
- WshShell.regWrite("HKEY_CURRENT_USER\\Software\\WPI\\CurrentInstall",0,"REG_DWORD"); // Save current position for reboots
- WshShell.regWrite("HKEY_CURRENT_USER\\Software\\WPI\\LastTopLine",topLine,"REG_DWORD");
- // WshShell.regWrite("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce\\WPIresume",'mshta "'+wpipath+'\\Common\\Installer.hta"');
- WshShell.regWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnceEx\\001\\","","REG_SZ");
- WshShell.regWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnceEx\\001\\1",'mshta "'+wpipath+'\\Common\\Installer.hta"',"REG_SZ");
- }
- catch (ex) {;}
-
- if (PlayAudioInInstaller)
- document.getElementById("MediaPlayerDIV").style.display='block';
- }
-
-
- function InstallPrograms()
- {
- position="installer.js";
- whatfunc="InstallPrograms()";
-
- var i, j, tempCmd;
-
- // Make sure we use the real %CDROM% path
- hdd="";
-
- if (!ResumeInstall)
- {
-
- for (i=1; prog[i] != null; i++)
- {
- if (document.getElementById("chkbox"+i) && document.getElementById("chkbox"+i).checked)
- {
- programs[programs.length++] = new program(i);
- programs[programs.length-1].texti = i; // For InsertCatNames()
- ScanForEntries(new program(i));
- }
- }
- RebootEntryFound ? WshShell.regWrite("HKEY_CURRENT_USER\\Software\\WPI\\numCommands",numCommands,"REG_DWORD") : null; // Save maxCommands for reboots
-
- if (programs.length==0)
- return;
-
- if (!InstallByCategory)
- programs.sort(SortByOrdr);
- // else
- // programs=InsertCatNames();
- }
- if (programs.length==0)
- return;
-
- OpenLogFile();
- OpenRebootFile();
-
- if (!ResumeInstall)
- {
- if (ExecuteBeforeEnabled && ExecuteBefore != null)
- {
- programs.splice(0,0,new program(999998));
- programs[0].prog="Execute Before";
- programs[0].uid="EXECUTE_BEFORE";
- programs[0].ordr=0;
- programs[0].cat="WPI Built In";
- programs[0].cmd1=ExecuteBefore;
- totalLine++;
- }
-
- if (ExecuteAfterEnabled && ExecuteAfter != null)
- {
- programs.splice(programs.length,0,new program(999999));
- programs[programs.length-1].prog="Execute After";
- programs[programs.length-1].uid="EXECUTE_AFTER";
- programs[programs.length-1].ordr=0;
- programs[programs.length-1].cat="WPI Built In";
- programs[programs.length-1].cmd1=ExecuteAfter;
- totalLine++;
- }
-
- WriteLogLinePlain("\r\n"+getText(ListofProgsToInstall));
- for (i=0; programs[i] != null; i++)
- {
- if (programs[i].desc != "WPI Built In Category")
- {
- WriteLogLinePlain(" "+programs[i].prog);
- RebootEntry(programs[i]);
- }
- }
- }
-
- ShowInstaller();
- ResumeInstall ? i=CurrentInstall : i=0;
-
- for (i; i<programs.length && programs[i] != null; i++)
- {
- if (!ResumeInstall)
- {
- programs[i].success=false;
- programs[i].fail=false;
- }
- if (programs[i].desc=="WPI Built In Category")
- continue;
-
- UpdateInstallList(i,programs);
-
- if (!ResumeInstall)
- StartLogEntry(programs[i]);
-
- WshShell.regWrite("HKEY_CURRENT_USER\\Software\\WPI\\CurrentInstall",i,"REG_DWORD"); //Save current position for reboots
-
- if (!ResumeInstall)
- {
- WshShell.regWrite("HKEY_CURRENT_USER\\Software\\WPI\\LastExec",0,"REG_DWORD"); //Save current position for reboots
- tempCmd = eval('programs['+i+'].regb');
- if (programs[i].regb!=null && ReplacePath(tempCmd[0])!='')
- {
- WshShell.regWrite("HKEY_CURRENT_USER\\Software\\WPI\\curCommand",curCommand+1,"REG_DWORD"); //Save current command position for reboots
- InstallOne(i,'regb');
- UpdateProgressBar(Math.round(((++curCommand)/numCommands)*100));
- Pause(0,250);
- }
- }
-
- ResumeInstall ? j=LastExec+1 : j=1;
- for (j; j<=10; j++)
- {
- WshShell.regWrite("HKEY_CURRENT_USER\\Software\\WPI\\LastExec",j,"REG_DWORD"); //Save current position for reboots
- tempCmd = eval('programs['+i+'].cmd'+j);
- if (tempCmd!=null && ReplacePath(tempCmd[0])!='')
- {
- WshShell.regWrite("HKEY_CURRENT_USER\\Software\\WPI\\curCommand",curCommand+1,"REG_DWORD"); //Save current command position for reboots
- InstallOne(i,'cmd'+j);
- UpdateProgressBar(Math.round(((++curCommand)/numCommands)*100));
- Pause(0,250);
- }
- }
-
- if (!ResumeInstall || (ResumeInstall && LastExec<11))
- {
- WshShell.regWrite("HKEY_CURRENT_USER\\Software\\WPI\\LastExec",11,"REG_DWORD"); //Save current position for reboots
- tempCmd = eval('programs['+i+'].rega')
- if (programs[i].rega!=null && ReplacePath(tempCmd[0])!='')
- {
- WshShell.regWrite("HKEY_CURRENT_USER\\Software\\WPI\\curCommand",curCommand+1,"REG_DWORD"); //Save current command position for reboots
- InstallOne(i,'rega');
- UpdateProgressBar(Math.round(((++curCommand)/numCommands)*100));
- Pause(0,250);
- }
- }
-
- if (ResumeInstall)
- {
- LastExec != 12 ? WriteLogLine(getText(FinishedInstallation)) : null;
- ResumeInstall=false;
- RebootEntryFound=true;
- continue;
- }
- else
- {
- WshShell.regWrite("HKEY_CURRENT_USER\\Software\\WPI\\LastExec",12,"REG_DWORD");
- WriteLogLine(getText(FinishedInstallation));
- }
-
- while (document.getElementById("Pause").value == getText(btnResume))
- {
- Pause(0,250); //Pause the installation on user request
- if (!document.getElementById("Aborted").value) //Check for user abortion
- break;
- }
- if (!document.getElementById("Aborted").value) //Check for user abortion
- break;
- }
- if (!document.getElementById("Aborted").value)
- WriteLogLine("\r\n\r\n"+getText(InstallAbortedByUser));
-
- UpdateInstallList(10000000,programs);
- Pause(0,250);
-
- CloseLogFile();
- CloseRebootFile();
- LogInstallation=false;
- RebootInstallationLog=false;
- DeleteRebootFile();
-
- try
- {
- WshShell.regWrite("HKEY_CURRENT_USER\\Software\\WPI\\ResumeInstall",0,"REG_DWORD");
- WshShell.regDelete("HKEY_CURRENT_USER\\Software\\WPI\\LastExec");
- WshShell.regDelete("HKEY_CURRENT_USER\\Software\\WPI\\CurrentInstall");
- WshShell.regDelete("HKEY_CURRENT_USER\\Software\\WPI\\LastTopLine");
- WshShell.regDelete("HKEY_CURRENT_USER\\Software\\WPI\\curCommand");
- WshShell.regDelete("HKEY_CURRENT_USER\\Software\\WPI\\numCommands");
- WshShell.regDelete("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnceEx\\001\\1");
- WshShell.regDelete("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnceEx\\001\\");
- }
- catch (ex) {;}
-
- if (RestartComputer)
- {
- if (DoNotLoadDesktop)
- RestartSeconds=0;
-
- if (!RestartType)
- cmdLine='shutdown.exe -r -f -t '+RestartSeconds+' -c "'+getText(ComputerWillRestart)+'"';
- else
- cmdLine='shutdown.exe -s -f -t '+RestartSeconds+' -c "'+getText(ComputerWillShutdown)+'"';
- WshShell.Run(cmdLine,0,true);
- }
-
- Pause(2,0);
- }
-
-
- function InstallOne(item,cmdName)
- {
- position="installer.js";
- whatfunc="InstallOne()";
-
- var cmd, cmdLine, ReturnCode, result;
- var IsReboot=false;
-
- cmd=eval('programs['+item+'].'+cmdName);
- if (cmd==null || (cmdLine=ReplacePath(cmd[0]))=='')
- return;
-
- if (cmd[0].toUpperCase().indexOf("%REBOOT%")==0 || (ResumeInstall && cmd[0].toUpperCase().indexOf("SHUTDOWN.EXE")==0))
- IsReboot=true;
-
- if (cmdName=='regb' || cmdName=='rega')
- {
- if (!FileExists(cmdLine))
- {
- programs[item].fail=true;
- WriteRebootFail(item,true);
- cmdName=(cmdName=='regb') ? 'Reg Before' : 'Reg After';
- WriteLogLine(cmdName+' '+getText(FailFileDoesNotExist)+': RegEdit /S '+cmdLine);
-
- return;
- }
- if (cmdLine.indexOf(" ") != -1 && cmdLine.substr(0,1) != '"')
- cmdLine='"'+cmdLine+'"';
- cmdLine="RegEdit /S "+cmdLine;
- }
- else
- cmdLine=handleCommand(cmdLine);
-
- try
- {
- ReturnCode=WshShell.Run(cmdLine,1,true);
- result=getText(InstallSuccess);
- programs[item].success=true;
- WriteRebootSuccess(item,true);
- }
- catch(ex)
- {
- result=getText(InstallFail);
- programs[item].fail=true;
- WriteRebootFail(item,true);
- }
- cmdName=(cmdName=='regb') ? 'Reg Before' : (cmdName=='rega') ? 'Reg After' : cmdName;
- WriteLogLine(cmdName+' '+result+' ('+getText(ReturnedCode)+' '+ReturnCode+'): "'+cmdLine+'"');
-
- if (IsReboot) // Give some time for %reboot% to take affect
- Pause(3600,0);
- }
-
-
- function handleCommand(cmd)
- {
- position="installer.js";
- whatfunc="handleCommand()";
-
- var firstToken;
-
- if (cmd.indexOf(" ") != -1 && cmd.substr(0,1) != '"')
- {
- firstToken = cmd.substr(0,cmd.indexOf(" "));
- switch(firstToken.toUpperCase())
- {
- case 'FILECOPY':
- cmd = ("CMD /C " + cmd.replace(/FILECOPY/gi,'copy'));
- break;
-
- case 'FILEMOVE':
- cmd = ("CMD /C " + cmd.replace(/FILEMOVE/gi,'move'));
- break;
-
- case 'RENAME':
- cmd = ("CMD /C " + cmd.replace(/RENAME/gi,'ren'));
- break;
-
- case 'DELETE':
- cmd = ("CMD /C " + cmd.replace(/DELETE/gi,'del'));
- break;
-
- case 'MAKEDIR':
- cmd = ("CMD /C " + cmd.replace(/MAKEDIR/gi,'md'));
- break;
-
- case 'DIRCOPY':
- cmd = ("CMD /C " + cmd.replace(/DIRCOPY/gi,'xcopy') + " /I /E /Y");
- break;
-
- case 'DELDIR':
- cmd = ("CMD /C " + cmd.replace(/DELDIR/gi,'rd') + " /S /Q");
- break;
-
- default:
- if (FileExists(cmd))
- cmd='"'+cmd+'"';
- break;
- }
- }
-
- return (cmd);
- }
-
-
- function UpdateInstallList(pos,progs)
- {
- position="installer.js";
- whatfunc="UpdateInstallList()";
-
- var line, box="";
-
- if (pos>centerLine && topLine+maxLines<totalLine) //More lines than can be displayed
- {
- topLine++;
- WshShell.regWrite("HKEY_CURRENT_USER\\Software\\WPI\\LastTopLine",topLine,"REG_DWORD");
- }
-
- for (line=topLine; line<topLine+maxLines; line++)
- {
- if (line<pos)
- {
- if (progs[line].desc != "WPI Built In Category")
- {
- box+='<img src="../Themes/'+Theme+'/Install';
- box+=(progs[line].success ? (progs[line].fail ? 'Partial' : 'Success') : 'Fail');
- box+='.gif" border="0" width="11" height="11">';
- box+='<img src="../Themes/'+Theme+'/spacer.gif" border="0" width="2" height="1">';
- }
- }
- else
- {
- if (progs[line].desc != "WPI Built In Category")
- box+='<img src="../Themes/'+Theme+'/spacer.gif" border="0" width="13" height="1">';
- }
-
- box+='<font style="font-size:12px;">'+(line==pos ? '<b>'+progs[line].prog+'</b>' : progs[line].prog)+'</font><br>';
- }
-
- document.getElementById("Install_prog").innerHTML=box;
- }
-
-
- function ClearProgressBar()
- {
- position="installer.js";
- whatfunc="ClearProgressBar()";
-
- document.getElementById("PB_text").innerHTML="";
- document.getElementById("PB_bar").style.width=0;
- }
-
-
- function UpdateProgressBar(value)
- {
- position="installer.js";
- whatfunc="UpdateProgressBar()";
-
- if (value>=0 && value<=100)
- {
- if (value>9)
- document.getElementById("PB_text").innerHTML=parseInt(value)+"%";
- document.getElementById("PB_bar").style.width=(value*3)+"px";
- }
- }
-
-
- function InsertCatNames()
- {
- position="installer.js";
- whatfunc="InsertCatNames()";
-
- var programs2 = new Array();
- var curCat="";
- var i, j, k, progspercat;
-
- for (i=0; programs[i] != null; i++)
- {
- if (programs[i].cat != curCat[0])
- {
- // get a category's apps into temporary array and sort it
- curCat=programs[i].cat;
- progspercat = new Array();
- for (j=i; programs[j] != null; j++)
- {
- if (programs[j].cat == curCat[0])
- progspercat[progspercat.length++] = new program(programs[j].texti);
- else
- {
- progspercat.sort(SortByOrdr);
- // insert cat header
- progspercat.splice(0,0,new program(0));
- progspercat[0].prog="<b><i>"+curCat+"</i></b>";
- progspercat[0].uid="CATEGORY_"+curCat;
- progspercat[0].ordr=0;
- progspercat[0].desc="WPI Built In Category";
- progspercat[0].cat=curCat;
- totalLine++;
-
- // append array to programs array
- for (k=0; k<progspercat.length; k++)
- programs2[programs2.length++]=progspercat[k];
- break;
- }
- }
- }
- }
-
- programs=[];
-
- return programs2;
- }
-