//Copyright (c) Microsoft Corporation. All rights reserved.
/* global variables */
var g_bOSIsServer,g_aProductIDs;
var g_bMandatoryUpdatePresent;
var g_sMandatoryUpdateIndexes;
var g_aSuccessfulUpdatesGroupedByProduct = new Array();
var g_aRemainingUpdatesGroupedByProduct = new Array();
var g_aFailedUpdatesGroupedByProduct = new Array();
var g_aSuccessfulMandatoryUpdates = new Array();
var g_aFailedMandatoryUpdates = new Array();
var g_bSPMode = false;//variable that tells to scan for superseded updates
var g_bSPPresent = false; // tells if SP is present and needs to be displayed
var g_iSPPresentIndex = -1;
var g_iSPIDsIndex = -1;//index of the applicable SP in the spUpdateIds array
var g_iSPPresentID= -1;
var g_bSPCoolOff = false;//cool off applicable SP
var g_bSPAU = false;//AU mode for applicable SP
var g_bHighPriority = false; // tells if high priority update is present
var g_bPsfMSPStringPresent = false;
var g_sPsfString = "windowspatch";
var g_sMSPString = "windowsinstaller"
var g_aProductsDetected;
var g_iProductIndex = -1;//index of the product jump page
var g_sPName ="";
var g_bCallLevel = false; //varriable used to display call level or update level genric text in install result page
/* global variables */
/* constants */
var conInstallNotStarted = 0;
var conInstallSucceeded = 2;
var conInstallAborted = 5;
var conInstallFailed = 4;
var conUpdateTypeSoftware = 1;
var conSecPerMBPsf = 18
var conBiasPsf = 45;
var LEGITCHECK_VLK_INVALID = 3;
/* constants */
var sTOC;
var g_oUpdateSearcher, g_oSearchJob, g_oSearchJobHidden, g_oSearchResult, g_oSearchResult, g_bSearchTypeHidden, g_bSearchTimeout, g_oUpdateInstaller, g_oWebProxy, g_oWebSession;
// Note that the 20 minute timeout value below no longer causes the site to timeout
// see the fnSearchOperationTimeout function for further details.
var g_iSearchTimeoutValue = 1200000;
var g_iProxyRetry = 0, g_iProxyRetryMax = 3;
var g_sDelim = "==@#$%^==";
var g_aCat = new Array(); // This array contains data for the Categories
var g_iSingleExclusive = -1
var g_iSingleEXDownloadPriority = 9;
var g_sExlusiveUpdates = "" ;
var g_iHighestDownloadPriority = 9;
var g_sSortExclusive = "";
var g_aMFDURLs = new Array();
var g_aMFDURLIndex = new Array();//Two parallel arrays that contain URL and index
var g_sInstallResult = "";
function fnInitDetect(){
var i, j;
fnTrace("fnInitDetect");
g_bSearchTimeout = false;
g_bMandatoryUpdatePresent = false;
if (!g_bMUSite){
g_sQSProductName = "";
}
try {
if(!g_bSPMode){
g_oWebSession = g_oControl.CreateObject("Microsoft.Update.Session");
if(g_bMUSite) {
g_oWebSession.ClientApplicationID = "MicrosoftUpdate";
} else {
g_oWebSession.ClientApplicationID = "WindowsUpdate";
}
g_oUpdateSearcher = g_oWebSession.CreateUpdateSearcher();
if(g_bMUSite) {
var oServiceManager = g_oControl.CreateObject("Microsoft.Update.ServiceManager");
var UpdateServices = oServiceManager.Services;
for (i = 0; i < UpdateServices.Count; i++) {
if (UpdateServices.Item(i).ServiceID == g_sMUServiceGuid) {
g_bClientIsRegistered = true;
break;
}
}
//Add service for managed client
if(g_bClientIsRegistered == false) {
var AuthCabPath = g_oControl.DownloadAuthCab();
oServiceManager.AddService(g_sMUServiceGuid, AuthCabPath);
}
g_oUpdateSearcher.ServerSelection = 3;
g_oUpdateSearcher.ServiceID = g_sMUServiceGuid;
oServiceManager = null;
} else {
g_oUpdateSearcher.ServerSelection = 2;
}
g_sSPExclude = ""
} else {
g_sSPExclude = " and UpdateID != '" + g_iSPPresentID + "'"; // condition to exclude SP
}
g_bSearchTypeHidden = false;
g_oUpdateSearcher.Online = true;
g_oSearchJob = g_oUpdateSearcher.BeginSearch("IsInstalled=0 and IsHidden=0" + g_sSPExclude, fnSearchOperationCallBack, 0); // Async Search Operation for non-hidden updates
window.setTimeout("fnSearchOperationTimeout()", g_iSearchTimeoutValue);
}
catch(e){
g_bScanning = false;
fnDisplayErrorPage(e.number, false);
return false;
}
}
function fnSearchOperationTimeout() {
//-------------------------------------------------------------------------------
// Bug fix: 979175
//
// This method no longer causes the site to display a timeout message so it
// is being updated to simply return false as it did previously when the search
// was considered successful.
//-------------------------------------------------------------------------------
fnTrace("fnSearchOperationTimeout");
return false;
}
// fnCheckForPidWarning(oSearchResult)
//
// SUMMARY:
// Helper function to loop through warnings looking for ERROR_INVALID_PID.
//
// PARAMS:
// oSearchResult: search result returned from search job to check for warnings.
//
// RETURNS:
// True if an ERROR_INVALID_PID warning is found and false otherwise.
//
function fnCheckForPidWarning(oSearchResult)
{
var bInvalidPid = false;
// Check for any warnings
var iWarnings = oSearchResult.Warnings.Count;
for(i = 0; i < iWarnings; i++) {
// If one of the warnings is ERROR_INVALID_PID (invalid process ID) then
// set a flag to ensure we'll only offer this user non-Windows updates
if(oSearchResult.Warnings.Item(i).HResult == ERROR_INVALID_PID) {
bInvalidPid = true;
break;
}
}
return bInvalidPid;
}
// fnProcessSearchResult(oSearchResult, oUpdateCollection)
//
// SUMMARY:
// Helper function to loop through updates from a search result and
// add them to a global collection.
//
// PARAMS:
// oSearchResult: search result containing 0 or more updates.
//
// RETURNS:
// True if at least one update is mandatory and false otherwise.
//
function fnProcessSearchResult(oSearchResult, oUpdateCollection)
{
// Get the collection of updates
var colUpdates = oSearchResult.Updates;
var bIsMandatoryUpdatePresent = false;
g_bMandatoryUpdatePresent = false;
// Loop through each update and add it to the collection
for(i = 0; i < colUpdates.Count; i++){
oUpdate = colUpdates(i);
// Watch for mandatory updates and flag it if we see one
if(oUpdate.IsMandatory)
g_bMandatoryUpdatePresent = bIsMandatoryUpdatePresent = true;
oUpdateCollection.Add(oUpdate);
}
return bIsMandatoryUpdatePresent;
}
// fnSearchOperationCallBack()
//
// SUMMARY:
// This method is called back by the client control when the search
// is complete or has encountered an error. It is used twice, once
// at the end of a non-hidden, online search, and again after another
// hidden, offline search which is initiated after the first
// non-hidden callback has been processed.
//
// RETURNS:
// False if an exception was thrown during processing or if the
// search timed out before this callback occurred.
//
function fnSearchOperationCallBack() {
// Trace this function
fnTrace("fnSearchOperationCallBack");
// Return value of this function
var bReturn = true;
// Variable to track any error returned related to WGA
var sWGAErrorCode;
// Flag to track if the user has a valid process ID
// (invalid PIDs may be detected during searching and returned
// as a warning in the code below)
var bInvalidPid = false;
// Variable to track if a mandatory update is present in the collection
var bIsMandatoryUpdatePresent = false;
// If the search has timed out then just return from this function
// because the fnSearchOperationTimeout function has already been called
// and the timeout error page is already diplaying to the end user.
if(g_bSearchTimeout)
bReturn = false;
else
{
// Handle any exception explicitly that occurs during this callback
try {
// If this function is being called for the first time after a hidden
// search has completed this global g_bSearchTypeHidden flag will be
// set true
if(g_bSearchTypeHidden && g_oSearchJobHidden.IsCompleted){
//save off the old state of the global mandatory update present variable
bIsMandatoryUpdatePresent = g_bMandatoryUpdatePresent;
// Call the fnProcessSearchResult function on the result of the search
// from the hidden search job
g_sSearchResultHidden = g_oUpdateSearcher.EndSearch(g_oSearchJobHidden);
// Save off the root category for later use when we build
// out a global category array
g_UpdateCategory = g_sSearchResultHidden.RootCategories;
// Process each update into the collection
fnProcessSearchResult(g_sSearchResultHidden, g_UpdateCol);
// Reset the proxy count so we can be ready any rescanning
g_iProxyRetry = 0;
//reset the global mandatory variable with the value saved off earlier
g_bMandatoryUpdatePresent = bIsMandatoryUpdatePresent
// Process all the updates that we have now after the second search
fnEndDetectUpdates(g_bMandatoryUpdatePresent, bInvalidPid);
}
// This is the callback from the first search, check to ensure it is completed
else if(!g_bSearchTypeHidden && g_oSearchJob.IsCompleted)
{
// Get the result from the first search job
g_sSearchResult = g_oUpdateSearcher.EndSearch(g_oSearchJob);
// Check for warnings
bInvalidPID = fnCheckForPidWarning(g_sSearchResult);
//Create a new global collection where all updates will be consolidated
g_UpdateCol = g_oControl.CreateObject("Microsoft.Update.UpdateColl");
// Process results and record presence of anything mandatory
g_bMandatoryUpdatePresent = fnProcessSearchResult(g_sSearchResult, g_UpdateCol);
// Reset global variables for a second search
g_iProxyRetry = 0;
g_bSearchTypeHidden = true;
g_oUpdateSearcher.Online = false;
// Async search operation for updates not installed and hidden
g_oSearchJobHidden = g_oUpdateSearcher.BeginSearch("IsInstalled = 0 and IsHidden = 1" + g_sSPExclude, fnSearchOperationCallBack, 0);
}
}
catch(e)
{
// Indicate we've hit a problem
bReturn = false;
if(e.number == PROXY_ERROR_CODE || e.number == PROXY_ERROR_CODE2) {
// If this is a proxy problem and we've hit our limit for proxy problems
// then display an error
if(g_iProxyRetry++ == g_iProxyRetryMax) {
// We are going to stop scanning as a result of this problem
g_bScanning = false;
g_iProxyRetry = 0;
fnDisplayErrorPage(PROXY_ERROR_CODE, false);
}
// Otherwise ask for proxy credentials and retry the current type of search
else
{
// If this is the first time we've seen a proxy problem
// we'll need to create an MS.Update.WebProxy object
if(g_iProxyRetry == 1) {
g_oWebProxy = g_oControl.CreateObject("Microsoft.Update.WebProxy");
g_oWebSession.WebProxy = g_oWebProxy;
}
g_oWebProxy.PromptForCredentials(window, L_ProxyTitle_Text);
// Continue the type of search we were doing when we hit the problem (stay in scanning mode)
if(g_bSearchTypeHidden) {
g_oSearchJobHidden = g_oUpdateSearcher.BeginSearch("IsInstalled = 0 and IsHidden = 1" + g_sSPExclude, fnSearchOperationCallBack, 0);
} else {
g_oSearchJob = g_oUpdateSearcher.BeginSearch("IsInstalled = 0 and IsHidden = 0" + g_sSPExclude, fnSearchOperationCallBack, 0);
}
}
}
else
{
// If its not just a proxy problem then we are definitely done trying to scan
g_bScanning = false;
// If the error number is one of the valuess below then the valid license key
// check failed and we should treat this user as non-genuine
if (e.number == -2145107928 || e.number == -2145124311) // -2145107928 and -2145124311
{
sWGAErrorCode = LEGITCHECK_VLK_INVALID;
fnDisplayGenuineValidationPage(false, sWGAErrorCode);
}
else
{
fnDisplayErrorPage(e.number, false);
}
}
}
}
// Return from the function
return bReturn;
}
// fnEndDetectUpdates(bIsMandatoryUpdatePresent, bInvalidPid)
//
// SUMMARY:
// Helper function to process updates, perform LegitCheck and
// call methods to show results if applicable.
//
// PARAMS:
// bIsMandatoryUpdatePresent: Indicates if the global collection of
// updates contains a mandatory update.
// bInvalidPid: Indicates if any error has been encountered indicating
// that an invalid process ID was detected during scanning.
//
// RETURNS:
// False if any error condition is encountered and true otherwise.
//
function fnEndDetectUpdates(bIsMandatoryUpdatePresent, bInvalidPid) {
// Trace this function
fnTrace("fnEndDetectUpdates");
// Declare this function's return value
var bReturn = true;
// Flag to determine if Windows content should be shown
var bShowWindowsContent = true;
// Variable to track any error returned related to WGA
// Default this to "0" in case we can't perform this check
// due to the control not being available on this platform.
var sWGAErrorCode = "0";
// Track globally that we have finished detecting updates
g_bDetectedItems = true;
// If there are mandatory updates present then always show them because
// this may be the WGA control or something else that could fix a problem
if (bIsMandatoryUpdatePresent){
// For mandatory updates we still need to build out the category arrays
// so they can be used for installation purposes (include Windows content)
if(!fnBuildCategoryArrays(true)){
fnDisplayErrorPage(conErrorUnknownCollectionError, false);
bReturn = false;
}else{
fnDisplayMandatoryUpdates();
}
}
// If there are no mandatory updates then...
else
{
// Determine if we already have a PID error
if (bInvalidPid) {
bReturn = false;
// Set a different error if this is MU instead of WU
if(g_bMUSite)
// Set the value of sWGAErrorCode to a MU specific error
sWGAErrorCode = conInvalidPidMU;
else
sWGAErrorCode = ERROR_INVALID_PID;
}
// We only need a WGA test if we don't already have the PID error
else
{
// Only test on platforms where the genuine control is available
if( // 5.1 = Windows XP (any edition)
g_oControl.GetOSVersionInfo(0,0) == 5
&& g_oControl.GetOSVersionInfo(1,0) == 1
){
// Determine if we have a genuine user via the WGA control before
// building the category arrays (we will eliminate the windows product
// family if the user is non-genuine)
try
{
// No codebase necessary since the WGA control is delivered via mandatory
// updates and we are only performing this check after mandatory updates
// have been installed
SunriseCtl.outerHTML = "";
if(SunriseCtl.object != null)
{
SunriseCtl.EnablePingbacks = (g_bWGAEnablePingback ? true : false);
sWGAErrorCode = SunriseCtl.LegitCheck();
if(sWGAErrorCode != "0" && sWGAErrorCode != "6")
bShowWindowsContent = false;
}else
{
// Set a special error to indicate that the WGA control was not present
// this will be sent to WGA if that is the case and no mandatory updates
// were presented to the user
sWGAErrorCode = 15;
bShowWindowsContent = false;
}
}
catch (e)
{
// If the control doesn't exist or if an error is thrown, assume user is not legit.
fnTrace("WGAControlInitializationFailure=" + e.number);
// Use the HRESULT from e.number as the error code
sWGAErrorCode = e.number;
// No windows content for non-genuine users
bShowWindowsContent = false;
}
}
// Build out the category arrays
if(fnBuildCategoryArrays(bShowWindowsContent)) {
// If WGA generated an error then show the genuine validation page
if(sWGAErrorCode != "0" && sWGAErrorCode != "6") {
fnDisplayGenuineValidationPage(false, sWGAErrorCode);
bReturn = false;
}
// Otherwise show the results
else {
fnShowResultlist();
}
}
// If fnBuildCategoryArrays evaluated to false then display
// and unknown error page
else {
fnDisplayErrorPage(conErrorUnknownCollectionError, false);
bReturn = false;
}
}
}
return bReturn;
//g_bScanning = false;
}
function fnShowResultlist(){
var iCriticalUpdatesCount, sUpdateArrayIndexes, aMandatoryUpdateIndexes, iUpdateResultCode, iInstallColCount, oUpdateInstallResult, iMandatoryUpdateCount, oInstallationResult, oUpdateInstaller, oInstallCol, i;
var bSomeFailed = false;
var j = 0;
var k = 0;
var sProductUpdateArrayIndexes;
if (g_bMandatoryUpdatePresent){ // then install mandatory updates first
g_bIsRebootRequired = g_oControl.IsRebootRequired;
if (g_bIsRebootRequired) {
fnDisplayErrorPage(conErrorRebootRequired, true);
return false;
}
oInstallCol = g_oControl.CreateObject("Microsoft.Update.UpdateColl");
aMandatoryUpdateIndexes = g_sMandatoryUpdateIndexes.split(",");
iMandatoryUpdateCount = aMandatoryUpdateIndexes.length;
for(i = 0; i < iMandatoryUpdateCount; i++) {
oInstallCol.Add(parent.g_UpdateCol(aMandatoryUpdateIndexes[i]));
parent.g_aUpdate[aMandatoryUpdateIndexes[i]].InBasket = false; // Bug #897127
}
oUpdateInstaller = g_oWebSession.CreateUpdateInstaller();
oUpdateInstaller.Updates = oInstallCol;
iInstallColCount = oInstallCol.Count;
oUpdateInstaller.ParentWindow = window;
oInstallationResult = oUpdateInstaller.RunWizard(parent.L_InstallTitle_Text);
g_sInstallResult = oInstallationResult.HResult;
g_aSuccessfulMandatoryUpdates.length = 0;
g_aFailedMandatoryUpdates.length = 0;
for(i = 0; i < iInstallColCount; i++) {
oUpdateInstallResult = oInstallationResult.GetUpdateResult(i);
iUpdateResultCode = oUpdateInstallResult.ResultCode;
if (iUpdateResultCode == conInstallSucceeded){
g_aSuccessfulMandatoryUpdates[j] = new String();
g_aSuccessfulMandatoryUpdates[j++].Title = oInstallCol(i).Title;
if ('undefined' != typeof(conWerMode) && conWerMode == iWerQueryModeExpress && oInstallCol(i).Identity.UpdateID == sWerUpdateId ){
g_aQueryString[1] = "IssueType=UserInstall";
fnPingServer(g_aQueryString,"//go.microsoft.com/fwlink/?LinkId=23428");
}
}
else {
g_aFailedMandatoryUpdates[k] = new String();
g_aFailedMandatoryUpdates[k].Title = oInstallCol(i).Title;
g_aFailedMandatoryUpdates[k++].ErrorCode = oUpdateInstallResult.HResult;
bSomeFailed = true;
if ('undefined' != typeof(conWerMode) && conWerMode == iWerQueryModeExpress && oInstallCol(i).Identity.UpdateID == sWerUpdateId ){
g_aQueryString[1] = "IssueType=SetupFail";
fnPingServer(g_aQueryString,"//go.microsoft.com/fwlink/?LinkId=23428");
}
}
if(oUpdateInstallResult.RebootRequired) {
g_bIsRebootRequired = true;
}
}
fnDisplayInstallStatus(conInstallStatusMandatory);
return false;
}
if((g_bExpressScan && !(g_bSPCoolOff || g_bSPAU)) || (g_iHighestDownloadPriority == 0)) g_bSPPresent = false; // set Sp present to false if any very high priority updates are present
if ((!g_bExpressScan && (!g_bSPPresent || g_iHighestDownloadPriority == 0)) || ('undefined' != typeof(conWerMode) && conWerMode == iWerQueryModeHardwareAll) ) {
fnCreateTocTree();
eTOC.eAvailableUpdatesTable.style.display = "block";
}
iCriticalUpdatesCount = fnGetUpdateCount();
if (g_bExpressScan) fnEndTOCDetectUpdates(conExpressInstall);
g_iConsumerBasketCount = iCriticalUpdatesCount;
if (!g_bExpressScan) {
if(g_sQSProductName != "") {
if(g_iProductIndex != -1){
sLinkId = "product" + g_iProductIndex;
sProductUpdateArrayIndexes = eTOC.document.all[sLinkId][0].UpdateArrayIndexes;
fnEndTOCDetectUpdates(conResultsBasket);
fnPostData(sProductUpdateArrayIndexes, conConsumerURL + "resultslist.aspx?" + conQueryString + "&id=" + conProduct + "&LinkId=" + sLinkId);
} else{
fnEndTOCDetectUpdates(conResultsBasket);
eContent.location.href = "thanks.aspx?thankspage=12&" + conQueryString; // fix for bug 895683
}
//set this to blank if the user goes to home page and does a custom or express scan it will be treated as normal scan rather than product jump page scan
g_sQSProductName = "";
}
else if ('undefined' != typeof(conWerMode) && conWerMode == iWerQueryModeHardwareAll ){ //WER scenario
fnEndTOCDetectUpdates(conResultsBasket);
fnDisplayHardwareUpdates();
}
else if(g_bSPPresent && g_iHighestDownloadPriority != 0){
fnEndTOCDetectUpdates(conExpressInstall);
fnDisplaySPUpdate();
}else{
fnEndTOCDetectUpdates(conResultsBasket);
fnDisplayCriticalUpdates();
}
}
else {
fnEndTOCDetectUpdates(conExpressInstall);
if((g_bSPCoolOff || g_bSPAU) && g_bSPPresent && g_iHighestDownloadPriority != 0){
fnDisplaySPUpdate();
}else{
sUpdateArrayIndexes = fnGetCategoryLevelUpdates(conCategoryCritical,null);
fnPostData(sUpdateArrayIndexes, conConsumerURL + "resultslist.aspx?" + conQueryString + "&id=" + conExpressInstall);
}
}
}
function fnDisplayMandatoryUpdates(){
fnTrace("fnDisplayMandatoryUpdates");
fnPostData(g_sMandatoryUpdateIndexes, conConsumerURL + "splash.aspx?" + conQueryString + "&page=" + conSplashMandatoryUpdates);
}
function fnDisplaySPUpdate(){
fnTrace("fnDisplaySPUpdate");
fnPostData(g_iSPPresentIndex, conConsumerURL + "servicepack.aspx?" + conQueryString + "&page=" + conServicePack);
}
//
// Starts up the Run-wizard and installs the updates
//
function fnInstallUpdates(exclusiveIndex){
//Build an update collection of only the updates that are selected into the basket
var i, ii, iUpdateCount, iInstallColCount, iUpdateResultCode, iMFDUpdateIndexCount, l, j, k , m;
var bInBasket = false, bFailed;
var aInstallColIndexes, aMFDUpdateIndexes, aRemainingUpdates, aSuccessfulUpdates, aFailedUpdates;
var sInstallColIndexes;
var oUpdateInstallResult;
sInstallColIndexes = "";
j = 0;
k = 0;
m = 0;
aRemainingUpdates = new Array();
aSuccessfulUpdates = new Array();
aFailedUpdates = new Array();
fnTrace("fnInstallUpdates");
iUpdateCount = g_aUpdate.length;
g_bIsRebootRequired = g_oControl.IsRebootRequired;
if (g_bIsRebootRequired) {
fnDisplayErrorPage(conErrorRebootRequired, true);
return false;
}
for(i = 0; i < iUpdateCount; i++) {
if(g_aUpdate[i].InBasket) {
bInBasket = true;
break;
}
}
//If an exclusive in basket, remove all but first exclusive
if(exclusiveIndex != -1) {
for(i = 0; i < iUpdateCount; i++) {
g_aUpdate[i].InBasket = false;
}
g_aUpdate[exclusiveIndex].InBasket = true;
bInBasket = true;
}
if(bInBasket) {
try {
//Create a new collection and add the selected updates
g_InstallCol = g_oControl.CreateObject("Microsoft.Update.UpdateColl");
g_aRemainingUpdatesGroupedByProduct.length = 0;
for(i = 0; i < iUpdateCount; i++) {
if (g_aUpdate[i].MFDIndex != "-1"){
if(g_aUpdate[i].InBasket) {
g_InstallCol.Add(g_UpdateCol(i));
sInstallColIndexes += i + ",";
if(g_aUpdate[i].MFDIndex != "") {
aMFDUpdateIndexes = g_aUpdate[i].MFDIndex.split(",");
iMFDUpdateIndexCount = aMFDUpdateIndexes.length;
for(ii=0; ii < iMFDUpdateIndexCount-1; ii++) {
g_InstallCol.Add(g_UpdateCol(aMFDUpdateIndexes[ii]));
sInstallColIndexes += aMFDUpdateIndexes[ii] + ",";
}
}
} else {
if(g_aUpdate[i].IsCritical && !g_aUpdate[i].IsHidden && !g_aUpdate[i].Exclude ) {
aRemainingUpdates[m] = new String();
aRemainingUpdates[m].Product = g_aUpdate[i].Company + " " + g_aUpdate[i].Product;
aRemainingUpdates[m++].Title = g_UpdateCol(i).Title;
}
}
}
}
// Creates a parrallel array to g_InstallCol, storing the update indexes to retrieve product name
if (sInstallColIndexes != "") {
sInstallColIndexes = sInstallColIndexes.substr(0,sInstallColIndexes.length -1) ;
aInstallColIndexes = sInstallColIndexes.split(",");
}
if ( aRemainingUpdates.length != 0 ) g_aRemainingUpdatesGroupedByProduct = fnGroupUpdatesByProduct(aRemainingUpdates, false);
//Create the Installer object and pass it the Install collection
g_oUpdateInstaller = g_oWebSession.CreateUpdateInstaller();
g_oUpdateInstaller.Updates = g_InstallCol;
iInstallColCount = g_InstallCol.Count;
//Code for Installer.RunWizard
g_oUpdateInstaller.ParentWindow = window;
g_oInstallationResult = g_oUpdateInstaller.RunWizard(parent.L_InstallTitle_Text);
g_aSuccessfulUpdatesGroupedByProduct.length = 0;
g_aFailedUpdatesGroupedByProduct.length = 0;
g_sInstallResult = g_oInstallationResult.HResult;
//if (g_oInstallationResult.ResultCode != conInstallAborted){
eTOC.eHidden.onclick = null;
eTOC.fnEnableLink(eTOC.eHidden, false);
for(i = 0; i < iInstallColCount; i++) {
oUpdateInstallResult = g_oInstallationResult.GetUpdateResult(i);
iUpdateResultCode = oUpdateInstallResult.ResultCode;
if (iUpdateResultCode == conInstallSucceeded){
aSuccessfulUpdates[j] = new String();
aSuccessfulUpdates[j].Product = g_aUpdate[aInstallColIndexes[i]].Company + " " + g_aUpdate[aInstallColIndexes[i]].Product;
aSuccessfulUpdates[j++].Title = g_InstallCol(i).Title;
if ('undefined' != typeof(conWerMode) && conWerMode == iWerQueryModeExpress && g_InstallCol(i).Identity.UpdateID == sWerUpdateId ){
g_aQueryString[1] = "IssueType=UserInstall";
fnPingServer(g_aQueryString,"//go.microsoft.com/fwlink/?LinkId=23428");
}
}
else {
bFailed = true ;
if ('undefined' != typeof(conWerMode) && conWerMode == iWerQueryModeExpress && g_InstallCol(i).Identity.UpdateID == sWerUpdateId ){
g_aQueryString[1] = "IssueType=SetupFail";
fnPingServer(g_aQueryString,"//go.microsoft.com/fwlink/?LinkId=23428");
}
aFailedUpdates[k] = new String();
aFailedUpdates[k].Title = g_InstallCol(i).Title;
aFailedUpdates[k].Product = g_aUpdate[aInstallColIndexes[i]].Company + " " + g_aUpdate[aInstallColIndexes[i]].Product;
if(iUpdateResultCode== conInstallNotStarted){
aFailedUpdates[k++].ErrorCode = g_oInstallationResult.HResult;
}else {
aFailedUpdates[k++].ErrorCode = oUpdateInstallResult.HResult;
}
}
if(oUpdateInstallResult.RebootRequired) {
g_bIsRebootRequired = true;
}
}
if ( aSuccessfulUpdates.length != 0 ) g_aSuccessfulUpdatesGroupedByProduct = fnGroupUpdatesByProduct(aSuccessfulUpdates,false);
if ( aFailedUpdates.length != 0 ) g_aFailedUpdatesGroupedByProduct = fnGroupUpdatesByProduct(aFailedUpdates,true);
if ('undefined' != typeof(conWerMode) && ( conWerMode == iWerQueryModeExpressAll || conWerMode == iWerQueryModeHardwareAll ) ){
if (bFailed){
g_aQueryString[1] = "IssueType=SetupFail";
}
else {
g_aQueryString[1] = "IssueType=UserInstall";
}
fnPingServer(g_aQueryString,"//go.microsoft.com/fwlink/?LinkId=23428");
}
g_oUpdateInstaller = null;
fnDisplayInstallStatus(conInstallStatusRegular);
//}
}
catch(e){
g_oUpdateInstaller = null;
fnDisplayErrorPage(e.number, true);
return false;
}
} else {
alert(parent.L_RListBasketUpdatesNotAvailableText_Text);
}
}
//
// Creates an array of update titles grouped by product or combination of product and errorcode
//
function fnGroupUpdatesByProduct(aUpdates, bErrorCodePresent){
var iUpdateCount, iGroupByElementCount, i, j, k;
var sGroupByElement, sProductAndErrorCode;
j = 0;
k = 0;
var aGroupByElements = new Array();
var aGroupedUpdates = new Array();
iUpdateCount = aUpdates.length;
for (i = 0; i < iUpdateCount; i++){
if (bErrorCodePresent){
aGroupByElements[j++] = aUpdates[i].Product + "|" + aUpdates[i].ErrorCode ;
}
else {
aGroupByElements[j++] = aUpdates[i].Product;
}
}
aGroupByElements = fnRemoveDuplicates(aGroupByElements); // Creates an array of unique elements on which the update titles would be grouped
iGroupByElementCount = aGroupByElements.length;
for (i = 0; i < iGroupByElementCount; i++){
sGroupByElement = aGroupByElements[i];
aGroupedUpdates[k] = new String();
if (bErrorCodePresent){
aGroupedUpdates[k].ProductAndErrorCode = sGroupByElement;
aGroupedUpdates[k].Title = "";
for (j = 0; j < iUpdateCount; j++){
sProductAndErrorCode = aUpdates[j].Product + "|" + aUpdates[j].ErrorCode;
if (sProductAndErrorCode == sGroupByElement){
aGroupedUpdates[k].Title += aUpdates[j].Title + "|@|";
}
}
}
else {
aGroupedUpdates[k].Product = sGroupByElement;
aGroupedUpdates[k].Title = "";
for (j = 0; j < iUpdateCount; j++){
if (aUpdates[j].Product == sGroupByElement){
aGroupedUpdates[k].Title += aUpdates[j].Title + "|@|";
}
}
}
if (aGroupedUpdates[k].Title != "") aGroupedUpdates[k].Title = aGroupedUpdates[k].Title.substr(0,aGroupedUpdates[k].Title.length -3);
k++;
}
return aGroupedUpdates;
}
function fnDisplayInstallStatus(iPage) {
fnTrace("fnDisplayInstallStatus");
eContent.location.href = "InstallStatus.aspx?page=" + iPage + "&" + conQueryString;
}
function window.onbeforeunload(){
fnTrace("onbeforeunload");
try {
g_oSearchJob.RequestAbort();
g_oSearchJob.CleanUp();
}
catch(e) {}
}
/* Plots the TOC tree for categories */
function fnCreateTocTree(){
var bRemoved , i, bAddExtraLiBlob, sCriticalId, sOptionalSoftwareId, sOptionalHardwareId, sBetaId;
sCriticalId = conCategoryCritical;
sOptionalSoftwareId = conCategorySoftware;
sOptionalHardwareId = conCategoryHardware;
sBetaId = conCategoryBeta;
sTOC = "