home *** CD-ROM | disk | FTP | other *** search
Wrap
' *** ' *** -------------------------------------------------------------------------- ' *** Filename: DiskProtect.vbs ' *** -------------------------------------------------------------------------- ' *** Description: Code for the Windows Disk Protection HTA ' *** -------------------------------------------------------------------------- ' *** Version: 1.0 ' *** Notes: Used by DiskProtect.hta ' *** -------------------------------------------------------------------------- ' *** Copyright (C) Microsoft Corporation 2005, All Rights Reserved ' *** -------------------------------------------------------------------------- ' *** ' ~~~ ' ~~~ Force variables to be declared and turn off script error messages unless in DEBUG mode ' ~~~ Option Explicit If NOT DEBUG Then On Error Resume Next Else On Error Goto 0 ' ~~~ ' ~~~ Declare variables ' ~~~ Dim oDiskProtect, iWDPcmdVer Dim AVscriptPath,OtherscriptPath Dim strActionMessage, sRootFolder Dim oOS, colOperatingSystems, iInstallTime, iLastBootUpTime Dim sUpperFilter, iLocalDateTime, oLog, bBlackList, bWhiteList Dim arrTempArray, i, arrUpperFilters() ' *** ' *** --------------------------------------------------------------------------- ' *** Name: Init() ' *** --------------------------------------------------------------------------- ' *** Purpose: This function is executed before Load. ' *** --------------------------------------------------------------------------- ' *** Sub Init() If NOT DEBUG Then On Error Resume Next Else On Error Goto 0 Dim iOverlayTime iWDPcmdVer = 1 ' ~~~ Create objects Set oDiskProtect = New DiskProtect Set oLog = New Logging sRootFolder = GetRootFolder ' ~~~ Initiate logging & bind the logging object to the restrictions object Call oLog.Open(sRootFolder & "\log\DiskProtect.hta.log") Call oLog.Write("DiskProtect.hta : Started") oDiskProtect.Logging = oLog ' ~~~ Check reboot key before trying to run tool Set colOperatingSystems = oWMIService.ExecQuery _ ("Select * from Win32_OperatingSystem") For Each oOS in colOperatingSystems iLastBootUpTime = oOS.LastBootUpTime iLocalDateTime = oOS.LocalDateTime Next iInstallTime = RegRead(TOOLKITKEY & "SCTInstallTime") iOverlayTime = RegRead(TOOLKITKEY & "SCTOverlayTime") ' ~~~ Check UpperFilter registry key to ensure no other Disk Protection Software is installed ' ~~~ Read and record UpperFilters key in SCT registry oDiskProtect.GetStashUpperFilterKey() On Error Resume Next ' ~~~ Check only if Ewf not in UpperFilter If (InStr(UCase(sUpperFilter),","&"EWF"&",") < 1) or IsNull(sUpperFilter) Then ' ~~~ Set to Ewf if NUll If IsNull(sUpperFilter) Then ReDim Preserve arrUpperFilters(0) arrUpperFilters(0) = "Ewf" ' ~~~ Writes to UpperFilters key oDiskProtect.WriteUpperFilterKey() ' ~~~ Read and record UpperFilters key in SCT registry oDiskProtect.GetStashUpperFilterKey() ' ~~~ Registry modified... prompt for Restart If MsgBox(document.all("resRebootMessage").innerHTML, vbYesNo + vbCritical, sTitle) = vbYes Then bProcessing = False call Self.Close oDiskProtect.Reboot TerminateHTA() Exit Sub Else bProcessing = False call Self.Close TerminateHTA() Exit Sub End If Else ' ~~~ Black List Check Call oDiskProtect.UpperFilterCheck("BlackList") If bBlackList Then ' ~~~ Warn of Blacklist hit... Exit! msgbox vbCrlf & document.all("resDiskProtectionSoftware1").innerHTML & vbCrlf & document.all("resDiskProtectionSoftware2").innerHTML,vbOKOnly + vbInformation, sTitle bProcessing = False call Self.Close TerminateHTA() Exit Sub Else ' ~~~ White List Check Call oDiskProtect.UpperFilterCheck("WhiteList") If bWhiteList Then ' ~~~ Proceed with setting UpperFilters arrTempArray = Split(sUpperFilter, ",") For i = LBound(arrTempArray) to UBound(arrTempArray) ReDim Preserve arrUpperFilters(i) arrUpperFilters(i) = arrTempArray(i+1) Next ReDim Preserve arrUpperFilters(i-2) arrUpperFilters(i-2) = "Ewf" ' ~~~ Writes to UpperFilters key oDiskProtect.WriteUpperFilterKey() ' ~~~ Read and record UpperFilters key in SCT registry oDiskProtect.GetStashUpperFilterKey() ' ~~~ Registry modified... prompt for Restart If MsgBox(document.all("resRebootMessage").innerHTML, vbYesNo + vbCritical, sTitle) = vbYes Then bProcessing = False call Self.Close oDiskProtect.Reboot TerminateHTA() Exit Sub Else bProcessing = False call Self.Close TerminateHTA() Exit Sub End If Else Dim bPrompt bPrompt = False ' ~~~ Only warns of Gray UpperFilters if DEBUG If DEBUG then If MsgBox(vbCrlf & document.all("resUpperFilterGray1").innerHTML & vbCrlf & document.all("resUpperFilterGray2").innerHTML & vbCrlf & vbCrlf & document.all("resUpperFilterGray3").innerHTML, vbYesNo + vbInformation, sTitle) = vbYes Then bPrompt = True End If End If If Not(DEBUG) or bPrompt Then ' ~~~ Proceed with setting Gray UpperFilters arrTempArray = Split(sUpperFilter, ",") For i = LBound(arrTempArray) to UBound(arrTempArray) ReDim Preserve arrUpperFilters(i) arrUpperFilters(i) = arrTempArray(i+1) Next ReDim Preserve arrUpperFilters(i-2) arrUpperFilters(i-2) = "Ewf" ' ~~~ Writes to UpperFilters key oDiskProtect.WriteUpperFilterKey() ' ~~~ Read and record UpperFilters key in SCT registry oDiskProtect.GetStashUpperFilterKey() ' ~~~ Registry modified... prompt for Restart If MsgBox(document.all("resRebootMessage").innerHTML, vbYesNo + vbCritical, sTitle) = vbYes Then bProcessing = False call Self.Close oDiskProtect.Reboot TerminateHTA() Exit Sub Else bProcessing = False call Self.Close TerminateHTA() Exit Sub End If Else bProcessing = False call Self.Close TerminateHTA() Exit Sub End If End If End If End If On Error Goto 0 End If If iInstallTime > iLastBootUpTime Then If MsgBox(document.all("resRebootMessage").innerHTML, vbYesNo + vbCritical, sTitle) = vbYes Then bProcessing = False call Self.Close oDiskProtect.Reboot TerminateHTA() Exit Sub Else bProcessing = False call Self.Close TerminateHTA() Exit Sub End If End If If iOverlayTime > iLastBootUpTime Then If MsgBox(document.all("resRebootMessageOV").innerHTML, vbYesNo + vbCritical, sTitle) = vbYes Then bProcessing = False call Self.Close oDiskProtect.Reboot TerminateHTA() Exit Sub Else bProcessing = False call Self.Close TerminateHTA() Exit Sub End If End If If Not(oDiskProtect.OverlayCreated) and oDiskProtect.CalcOVSize = 0 and oDiskProtect.ForceOverlaySize = 0 Then If MsgBox (document.all("resNoOverlaySupport").innerHTML, vbYesNo + vbCritical, sTitle) = vbYes Then Call oShell.Run("diskmgmt.msc",0,False) End If bProcessing = False call Self.Close TerminateHTA() Exit Sub End If ' ~~~ If AU is enabled enable our WU Select Case RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\AUOptions") Case "4" oDiskProtect.WindowsUpdateScript = True Case "3" oDiskProtect.WindowsUpdateScript = True Case "2" oDiskProtect.WindowsUpdateScript = True Case "1" oDiskProtect.WindowsUpdateScript = False End Select End Sub ' *** ' *** ------------------------------------------------------------------------------ ' *** Name: Load() ' *** ------------------------------------------------------------------------------ ' *** Purpose: This subroutine is executed before a wizard page is displayed ' *** ------------------------------------------------------------------------------ ' *** Sub Load() If NOT DEBUG Then On Error Resume Next Else On Error Goto 0 ' ~~~ Unhide the two drop downs document.all("ddSchedule1").style.visibility = "visible" document.all("ddSchedule2").style.visibility = "visible" ' ~~~ Call the sub to enable body Call BodyDisable(False) ' ~~~ Call the sub to format the time Call FormatScheduleTime() document.all("rActCommit").title = document.all("lblPendingAction2").innerHTML ' ~~~ Default pending changes action is undo document.all("rActUndo").checked = True ' ~~~ Make radios reflect real status If oDiskProtect.Enabled Then document.all("radEnable").checked = True document.all("spStatus").innerHTML = document.all("lblStatusEnabled").innerHTML document.all("spEnable").innerHTML = document.all("resRebootAction3").innerHTML document.all("spDisable").innerHTML = document.all("resRebootAction4").innerHTML Call DisableSection2(False) Call DisableSection3(True) Else document.all("radDisable").checked = True document.all("spStatus").innerHTML = document.all("lblStatusDisabled").innerHTML document.all("spEnable").innerHTML = document.all("resRebootAction1").innerHTML document.all("spDisable").innerHTML = document.all("resRebootAction2").innerHTML Call DisableSection2(True) Call DisableSection3(True) End If ' ~~~ Make radios reflect real pending changes state Select Case oDiskProtect.BootCommand Case "SET_LEVEL" document.all("rActUndo").checked = True Case "COMMIT" document.all("rActCommit").checked = True Case "NO_CMD" document.all("rActRetain2").checked = True Case "ENABLE" document.all("radEnable").checked = True document.all("radDisable").checked = False document.all("rActUndo").checked = True Case "DISABLE" document.all("radEnable").checked = False document.all("radDisable").checked = True document.all("rActUndo").checked = True End Select If oDiskProtect.BootCommand = "NO_CMD" and Right(RegRead("HKLM\System\CurrentControlSet\Services\WDPOperations\parameters\Application"),7) = "restore" Then document.all("rActRetain1").checked = True End If ' ~~~ Default settings for windows update If oDiskProtect.WindowsUpdateScript Then document.all("rDPWinUpEnabled").checked = True Else document.all("rDPWinUpDisabled").checked = True End If If RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\AUOptions") = "" Then document.all("rDPWinUpEnabled").checked = False document.all("rDPWinUpDisabled").checked = False End If document.all("ddSchedule1").value = oDiskProtect.CriticalUpdateDay document.all("ddSchedule2").value = oDiskProtect.CriticalUpdateTime document.all("txtAntiVirusScript").value = GetFileName(oDiskProtect.AVUpdateScript) document.all("txtOtherScript").value = GetFileName(oDiskProtect.OtherUpdateScript) If document.all("radEnable").checked Then document.all("radEnable").focus() Else document.all("radDisable").focus() End If End Sub ' *** ' *** ------------------------------------------------------------------------------ ' *** Name: Validate() ' *** ------------------------------------------------------------------------------ ' *** Purpose: This function is executed before a wizard page is exited ' *** If this function returns false. The page does not exit. ' *** ------------------------------------------------------------------------------ ' *** Function Validate() If NOT DEBUG Then On Error Resume Next Else On Error Goto 0 Validate = validateUpdates() If Validate = True Then Validate = IsHibernationenabled() End If If Validate = True Then Validate = IsSystemBootSame() End If End Function ' *** ' *** ------------------------------------------------------------------------------ ' *** Name: Action() ' *** ------------------------------------------------------------------------------ ' *** Purpose: This subroutine performs the actual functionality of the tool ' *** ------------------------------------------------------------------------------ ' *** Sub Action() If NOT DEBUG Then On Error Resume Next Else On Error Goto 0 ToggleClose(True) Dim bReboot, bWDPReBoot bProcessing = True ' ~~~ To change the cursor to wait icon Call BodyDisable(True) ' ~~~ Set the default message strActionMessage = document.all("resActionNone").innerHTML bReboot = False bWDPReBoot = False ' ~~~ ------------------------- ' ~~~ If we are going to enable ' ~~~ ------------------------- If Not(oDiskProtect.Enabled) and GetRadio("dpReboot")="Enable" Then strActionMessage = document.all("resBlank").innerHTML oDiskProtect.Enable ' ~~~ Check for Overlay If oDiskProtect.OverlaySize() = 0 then bReboot = False ' ~~~ Set message strActionMessage = document.all("resNoOverlay").innerHTML Else ' ~~~ Set message strActionMessage = document.all("resActionEnable").innerHTML ' ~~~ Turn on critical updates If document.all("rDPWinUpEnabled").checked = True Then oDiskProtect.WindowsUpdateScript = True Else oDiskProtect.WindowsUpdateScript = False End If oDiskProtect.AVUpdateScript = AVscriptPath & document.all("txtAntiVirusScript").value oDiskProtect.OtherUpdateScript = OtherscriptPath & document.all("txtOtherScript").value oDiskProtect.CriticalUpdateDay = document.all("ddSchedule1").value oDiskProtect.CriticalUpdateTime = document.all("ddSchedule2").value Call oDiskProtect.EnableCriticalUpdates() bWDPReBoot = Showmodaldialog("WDPOn.hta","","dialogWidth:30;dialogHeight:18;Center:Yes;help:No;Resizable:No;") bProcessing = False call Self.Close() If bWDPReBoot Then oDiskProtect.Reboot TerminateHTA() End If Exit Sub End IF End If ' ~~~ -------------------------- ' ~~~ If we are going to disable ' ~~~ -------------------------- If oDiskProtect.Enabled and GetRadio("dpReboot")="Disable" Then strActionMessage = document.all("resActionDisable").innerHTML bReboot = True oDiskProtect.Disable ' ~~~ Turn off critical updates Call oDiskProtect.DisableCriticalUpdates() End If If oDiskProtect.BootCommand = "ENABLE" and GetRadio("dpReboot")="Disable" Then strActionMessage = document.all("resActionAlreadyOff").innerHTML bReboot = False oDiskProtect.Disable ' ~~~ Turn off critical updates Call oDiskProtect.DisableCriticalUpdates() End If ' ~~~ ----------------------------------------- ' ~~~ If enabled and leaving on, process action ' ~~~ ----------------------------------------- If oDiskProtect.Enabled and GetRadio("dpReboot")="Enable" Then Select Case GetRadio("dpAction") Case "Undo" If oDiskProtect.BootCommand <> "SET_LEVEL" Then strActionMessage = document.all("resPendingAction1").innerHTML bReboot = False oDiskProtect.UndoChanges End If Case "Commit" If oDiskProtect.BootCommand <> "COMMIT" Then strActionMessage = document.all("resPendingAction2").innerHTML bReboot = False oDiskProtect.Commit If document.all("rDPWinUpEnabled").checked = True Then oDiskProtect.WindowsUpdateScript = True Else oDiskProtect.WindowsUpdateScript = False End If oDiskProtect.AVUpdateScript = AVscriptPath & document.all("txtAntiVirusScript").value oDiskProtect.OtherUpdateScript = OtherscriptPath & document.all("txtOtherScript").value oDiskProtect.CriticalUpdateDay = document.all("ddSchedule1").value oDiskProtect.CriticalUpdateTime = document.all("ddSchedule2").value Call oDiskProtect.EnableCriticalUpdates() End If Case "Retain1" strActionMessage = document.all("resPendingAction3").innerHTML bReboot = False oDiskProtect.RetainChanges(True) Case "Retain2" strActionMessage = document.all("resPendingAction4").innerHTML bReboot = False oDiskProtect.RetainChanges(False) End Select End If ' ~~~ To change the cursor to wait icon Call BodyDisable(False) ' ~~~ -------------------------------------- ' ~~~ Display restart message if appropriate ' ~~~ -------------------------------------- If bReboot Then If MsgBox(strActionMessage & document.all("resRebootMessage2").innerHTML, vbYesNo + vbInformation, sTitle) = vbYes Then bProcessing = False call Self.Close oDiskProtect.Reboot Exit Sub End If Else MsgBox strActionMessage,vbOKOnly+vbInformation,sTitle End If bProcessing = False End Sub ' *** ' *** ------------------------------------------------------------------------------ ' *** Name: DisableSection2(bDisabled) ' *** ------------------------------------------------------------------------------ ' *** Purpose: Enables or disables sections of the screen ' *** ------------------------------------------------------------------------------ ' *** Sub DisableSection2(bDisabled) If NOT DEBUG Then On Error Resume Next Else On Error Goto 0 document.all("rActUndo").Disabled = bDisabled document.all("rActCommit").Disabled = bDisabled document.all("rActRetain1").Disabled = bDisabled document.all("rActRetain2").Disabled = bDisabled ' ~~~ Change the class If bDisabled Then document.all("tdPendingChange").className = "groupentrydisabled" Else document.all("tdPendingChange").className = "groupentry" End If End Sub ' *** ' *** ------------------------------------------------------------------------------ ' *** Name: DisableSection3(bDisabled) ' *** ------------------------------------------------------------------------------ ' *** Purpose: Enables or disables sections of the screen ' *** ------------------------------------------------------------------------------ ' *** Sub DisableSection3(bDisabled) ddSchedule1.Disabled = bDisabled ddSchedule2.Disabled = bDisabled rDPWinUpEnabled.Disabled = bDisabled rDPWinUpDisabled.Disabled = bDisabled txtAntiVirusScript.Disabled = bDisabled btnAntiVirusScript.Disabled = bDisabled txtOtherScript.Disabled = bDisabled btnOtherScript.Disabled = bDisabled ' ~~~ Change the class If bDisabled Then SetGreyHoverMessage() End If End Sub ' *** ' *** ------------------------------------------------------------------------------ ' *** Name: EnableDisableClick() ' *** ------------------------------------------------------------------------------ ' *** Purpose: Called when the disk protection status radio button is clicked ' *** ------------------------------------------------------------------------------ ' *** Sub EnableDisableClick() If NOT DEBUG Then On Error Resume Next Else On Error Goto 0 If document.all("spStatus").innerHTML = document.all("lblStatusEnabled").innerHTML Then If GetRadio("dpReboot")="Disable" Then document.all("rActUndo").checked = True Call DisableSection2(True) Call DisableSection3(True) Else Call DisableSection2(False) If GetRadio("dpAction")="Commit" Then Call DisableSection3(False) Else Call DisableSection3(True) End If End If Else If GetRadio("dpReboot")="Enable" Then Call DisableSection3(False) Call CheckVirusSoftware Else Call DisableSection3(True) End If End If End Sub ' *** ' *** ------------------------------------------------------------------------------ ' *** Name: BrowseForFileAV(txtControl) ' *** ------------------------------------------------------------------------------ ' *** Purpose: Called when the Browse for Anti virus is clicked ' *** ------------------------------------------------------------------------------ ' *** Sub BrowseForFileAV(txtControl) If NOT DEBUG Then On Error Resume Next Else On Error Goto 0 Dim oDialog Dim intResult ' ~~~ Create common dialog object and set options Set oDialog = CreateObject("UserAccounts.CommonDialog") oDialog.Filter = "Script Files (*.vbs; *.js; *.wsf)|*.vbs;*.js;*.wsf|Batch Files (*.cmd; *.bat)|*.cmd;*.bat|All Files (*.*)|*.*" oDialog.FilterIndex = 1 oDialog.InitialDir = ".\scripts\update" ' ~~~ Show dialog intResult = oDialog.ShowOpen if intResult <> 0 Then AVscriptPath = GetFilePath(oDialog.FileName) ' ~~~ Populate text field document.all(txtControl).value = GetFileName(oDialog.FileName) End If End Sub ' *** ' *** ------------------------------------------------------------------------------ ' *** Name: BrowseForFileOther(txtControl) ' *** ------------------------------------------------------------------------------ ' *** Purpose: Called when the Browse for Other updates is clicked ' *** ------------------------------------------------------------------------------ ' *** Sub BrowseForFileOther(txtControl) If NOT DEBUG Then On Error Resume Next Else On Error Goto 0 Dim oDialog Dim intResult ' ~~~ Create common dialog object and set options Set oDialog = CreateObject("UserAccounts.CommonDialog") oDialog.Filter = "Script Files (*.vbs; *.js; *.wsf)|*.vbs;*.js;*.wsf|Batch Files (*.cmd; *.bat)|*.cmd;*.bat|All Files (*.*)|*.*" oDialog.FilterIndex = 1 oDialog.InitialDir = ".\scripts\update" ' ~~~ Show dialog intResult = oDialog.ShowOpen if intResult <> 0 Then OtherscriptPath = GetFilePath(oDialog.FileName) ' ~~~ Populate text field document.all(txtControl).value = GetFileName(oDialog.FileName) End If End Sub ' *** ' *** ------------------------------------------------------------------------------ ' *** Name: GetFileName(file) ' *** ------------------------------------------------------------------------------ ' *** Purpose: Returns the file name from the full filename with path ' *** ------------------------------------------------------------------------------ ' *** private Function GetFileName(file) If NOT DEBUG Then On Error Resume Next Else On Error Goto 0 Dim arrFile Dim iupper if file <> "" Then arrFile = Split(file , "\") iupper = UBound(arrFile) GetFileName = arrFile(iupper) End If End Function ' *** ' *** ------------------------------------------------------------------------------ ' *** Name: GetFilePath(file) ' *** ------------------------------------------------------------------------------ ' *** Purpose: Returns the filepath from the full filename with path ' *** ------------------------------------------------------------------------------ ' *** private Function GetFilePath(file) If NOT DEBUG Then On Error Resume Next Else On Error Goto 0 Dim arrFile Dim FileName Dim path,iupper,total,length if file <> "" Then arrFile = Split(file , "\") iupper = UBound(arrFile) FileName = arrFile(iupper) total = len(file) length = len(Filename) GetFilePath = left(file,total-length) End If End Function ' *** ' *** ------------------------------------------------------------------------------ ' *** Name: CheckVirusSoftware ' *** ------------------------------------------------------------------------------ ' *** Purpose: validates the update scripts ' *** ------------------------------------------------------------------------------ ' *** private Function CheckVirusSoftware If NOT DEBUG Then On Error Resume Next Else On Error Goto 0 Dim sVersion, sRegpath, sScriptname, sRegVersion, sProductName, bAVInstalled Dim oXml, avXml, oProduct, oProdChildNode bAVInstalled = False If document.all("txtAntiVirusScript").value = "" then ' ~~~ Checks for different software can be done in many ways... currently done by looking for service ' ~~~ Might modify after other versions are investigated. AVscriptPath = GetRootFolder & "\scripts\update\" avXml = GetRootFolder & "\xml\AntiVirusUpdates.xml" Set oXml = CreateObject("MSXML2.DomDocument") Call oXml.Load(avXml) If oXml.parseError.errorCode = 0 Then ' ~~~ Loop through each of the AV products For Each oProduct in oXml.getElementsByTagName("Product") ' ~~~ Get the values of each product For Each oProdChildNode in oProduct.ChildNodes Select Case oProdChildNode.NodeName Case "Name" sProductName = oProdChildNode.Text Case "Version" sVersion = oProdChildNode.Text Case "RegKey" sRegpath = oProdChildNode.Text Case "UpdateScriptname" sScriptName = oProdChildNode.Text End Select Next ' ~~~ Get the AV version from registry sRegVersion = Left(RegRead(sRegpath),4) ' ~~~ If the registry exists for the product then proceed If sRegVersion <> "" Then ' ~~~ Compare the versions in registry and XML file If Instr(sRegVersion, sVersion) = 1 Then If Msgbox(sProductName & " " & resAVSoftwareDetected.innerHTML & vbCrlf & resSpecifyAVScript.innerHTML,vbYesNo + vbCritical, sTitle) = vbYes Then document.all("txtAntiVirusScript").value = GetFileName(AVscriptPath & "\" & sScriptName) End If End If bAVInstalled = True End If Next End If If bAVInstalled = False then AVscriptPath = "" Msgbox document.all("resNoAVSoftwareDetected").innerHTML & vbCrlf & document.all("resNoAVSoftwareAction").innerHTML, vbOkOnly + vbCritical, sTitle End If End If End Function ' *** ' *** ------------------------------------------------------------------------------ ' *** Name: validateUpdates() ' *** ------------------------------------------------------------------------------ ' *** Purpose: validates the update scripts ' *** ------------------------------------------------------------------------------ ' *** private Function validateUpdates() If NOT DEBUG Then On Error Resume Next Else On Error Goto 0 validateUpdates = true If document.all("txtAntiVirusScript").value = "" Then AVscriptPath = "" Else If RegRead(TOOLKITKEY & "AVUpdateScript") <> "" and AVscriptPath = "" then AVscriptPath = GetFilePath(RegRead(TOOLKITKEY & "AVUpdateScript")) If (oFso.FileExists(AVscriptPath & document.all("txtAntiVirusScript").value) <> true) Then If (oFso.FileExists(document.all("txtAntiVirusScript").value) <> true) Then validateUpdates = false MsgBox document.all("resValidAntivirusScript").innerHTML,16, sTitle document.all("txtAntiVirusScript").value = "" Exit Function Else validateUpdates = true AVscriptPath = "" End If End If End If If document.all("txtOtherScript").value = "" Then OtherscriptPath = "" Exit Function Else If RegRead(TOOLKITKEY & "OtherUpdateScript") <> "" and OtherscriptPath = "" then OtherscriptPath = GetFilePath(RegRead(TOOLKITKEY & "OtherUpdateScript")) If (oFso.FileExists(OtherscriptPath & document.all("txtOtherScript").value) <> true) Then If (oFso.FileExists(document.all("txtOtherScript").value) <> true) Then validateUpdates = false MsgBox document.all("resValidOtherScript").innerHTML,16, sTitle document.all("txtOtherScript").value = "" Exit Function Else validateUpdates = true OtherscriptPath = "" End If End If End If End Function ' *** ' *** ------------------------------------------------------------------------------ ' *** Name: TextClick(sId) ' *** ------------------------------------------------------------------------------ ' *** Purpose: Enables or Disables the Corresponding option next to the ' *** text that is being clicked ' *** ------------------------------------------------------------------------------ ' *** Sub TextClick(sId) If NOT DEBUG Then On Error Resume Next Else On Error Goto 0 Select Case sId Case "spEnable" document.all("radEnable").checked = True EnableDisableClick() Case "spDisable" document.all("radDisable").checked = True EnableDisableClick() Case "spActUndo" If document.all("tdPendingChange").classname = "groupentry" Then document.all("rActUndo").checked = True EnableDisableClick() End If Case "spActCommit" If document.all("tdPendingChange").classname = "groupentry" Then document.all("rActCommit").checked = True EnableDisableClick() End If Case "spActRetain1" If document.all("tdPendingChange").classname = "groupentry" Then document.all("rActRetain1").checked = True EnableDisableClick() End If Case "spActRetain2" If document.all("tdPendingChange").classname = "groupentry" Then document.all("rActRetain2").checked = True EnableDisableClick() End If Case "spWinUPEnabled" If Not document.all("rDPWinUpEnabled").disabled Then document.all("rDPWinUpEnabled").checked = True End If Case "spWinUPDisabled" If Not document.all("rDPWinUpDisabled").disabled Then document.all("rDPWinUpDisabled").checked = True End If End Select End Sub ' *** ' *** ------------------------------------------------------------------------------ ' *** Name: TextDisplay(sOptId) ' *** ------------------------------------------------------------------------------ ' *** Purpose: Sets the text to be displayed in the pop-up when mouse is ' *** hovered over controls. ' *** ------------------------------------------------------------------------------ ' *** Sub TextDisplay(sOptId) If NOT DEBUG Then On Error Resume Next Else On Error Goto 0 Select Case sOptId Case "spEnable" ' ~~~ Check the text displayed next to the radio If document.all("spEnable").innerHTML = document.all("resRebootAction1").innerHTML Then document.all("spEnable").title = document.all("lblRebootAction1").innerHTML Else document.all("spEnable").title = document.all("lblRebootAction3").innerHTML End If Case "spDisable" If document.all("spDisable").innerHTML = document.all("resRebootAction2").innerHTML Then document.all("spDisable").title = document.all("lblRebootAction2").innerHTML Else document.all("spDisable").title = document.all("lblRebootAction4").innerHTML End If Case "tdPendingChange" If document.all("tdPendingChange").classname = "groupentry" Then document.all("rActUndo").title = document.all("lblPendingAction1").innerHTML document.all("rActCommit").title = document.all("lblPendingAction2").innerHTML document.all("rActRetain1").title = document.all("lblPendingAction3").innerHTML document.all("rActRetain2").title = document.all("lblPendingAction4").innerHTML document.all("spActUndo").title = document.all("lblPendingAction1").innerHTML document.all("spActCommit").title = document.all("lblPendingAction2").innerHTML document.all("spActRetain1").title = document.all("lblPendingAction3").innerHTML document.all("spActRetain2").title = document.all("lblPendingAction4").innerHTML Else document.all("rActUndo").title = document.all("lblPendingAction1grey").innerHTML document.all("rActCommit").title = document.all("lblPendingAction2grey").innerHTML document.all("rActRetain1").title = document.all("lblPendingAction3grey").innerHTML document.all("rActRetain2").title = document.all("lblPendingAction4grey").innerHTML document.all("spActUndo").title = document.all("lblPendingAction1grey").innerHTML document.all("spActCommit").title = document.all("lblPendingAction2grey").innerHTML document.all("spActRetain1").title = document.all("lblPendingAction3grey").innerHTML document.all("spActRetain2").title = document.all("lblPendingAction4grey").innerHTML End If Case "txtAntiVirusScript" , "btnAntiVirusScript" If Not document.all("txtAntiVirusScript").disabled Then document.all("txtAntiVirusScript").title = document.all("lblAVScriptTxt").innerHTML End If If Not document.all("btnAntiVirusScript").disabled Then document.all("btnAntiVirusScript").title = document.all("lblAVScriptBtn").innerHTML End If Case "txtOtherScript" , "btnOtherScript" If Not document.all("txtOtherScript").disabled Then document.all("txtOtherScript").title = document.all("lblUpdateScriptTxt").innerHTML End If If Not document.all("btnOtherScript").disabled Then document.all("btnOtherScript").title = document.all("lblUpdateScriptBtn").innerHTML End If Case "spWinUPEnabled" If Not document.all("rDPWinUpEnabled").disabled Then document.all("spWinUPEnabled").title = document.all("lblWinUPEnabled").innerHTML End If Case "spWinUPDisabled" If Not document.all("rDPWinUpDisabled").disabled Then document.all("spWinUPDisabled").title = document.all("lblWinUPDisabled").innerHTML End If End Select End Sub ' *** ' *** ------------------------------------------------------------------------------ ' *** Name: IsSystemBootSame() ' *** ------------------------------------------------------------------------------ ' *** Purpose: Returns True if System and Boot Partitions are the same ' *** ------------------------------------------------------------------------------ ' *** Private Function IsSystemBootSame() If NOT DEBUG Then On Error Resume Next Else On Error Goto 0 IsSystemBootSame = True If (document.all("radEnable").checked = True) and (oDiskProtect.SystemBootSame() = False) and Not(oDiskProtect.Enabled) Then msgbox document.all("resSystemBootNotSame").innerHTML,vbOKOnly + vbInformation, sTitle IsSystemBootSame = True End If End Function ' *** ' *** ------------------------------------------------------------------------------ ' *** Name: IsHibernationenabled() ' *** ------------------------------------------------------------------------------ ' *** Purpose: Returns true if hibernation is enabled else returns false ' *** ------------------------------------------------------------------------------ ' *** Private Function IsHibernationenabled() If NOT DEBUG Then On Error Resume Next Else On Error Goto 0 IsHibernationenabled = True If (document.all("radEnable").checked = True) and (oDiskProtect.GetHibernation() = True) and Not(oDiskProtect.Enabled) Then If (msgbox(document.all("resHibernationWDPWarning").innerHTML,vbYesNo+vbInformation, sTitle) <> vbYes) Then IsHibernationenabled = False End If End If End Function ' *** ' *** ------------------------------------------------------------------------------ ' *** Name: ToggleClose(bToggle) ' *** ------------------------------------------------------------------------------ ' *** Purpose: This subroutine is executed to toggle the Finish button. ' *** ------------------------------------------------------------------------------ ' *** Sub ToggleClose(bToggle) If NOT DEBUG Then On Error Resume Next Else On Error Goto 0 If bToggle = True Then btnFinish.disabled = True btnFinish.style.cursor = "auto" Else btnFinish.disabled = False btnFinish.style.cursor = "hand" End If End Sub ' *** ' *** ------------------------------------------------------------------------------ ' *** Name: HTAKeyDown() ' *** ------------------------------------------------------------------------------ ' *** Purpose: This is the handler function for tool specific key controls ' *** ------------------------------------------------------------------------------ ' *** Sub HTAKeyDown() If NOT DEBUG Then On Error Resume Next Else On Error Goto 0 End Sub ' *** ' *** ------------------------------------------------------------------------------ ' *** Name: WDPRestart() ' *** ------------------------------------------------------------------------------ ' *** Purpose: This is called from the WDPOn.HTA. This functions restarts ' *** the system. ' *** ------------------------------------------------------------------------------ ' *** Sub WDPRestart() If NOT DEBUG Then On Error Resume Next Else On Error Goto 0 ' ~~~ To restart the system if yes is clicked in the WDPOn.hta window.returnvalue = True Self.Close() End Sub ' *** ' *** ------------------------------------------------------------------------------ ' *** Name: SetGreyHoverMessage() ' *** ------------------------------------------------------------------------------ ' *** Purpose: This method sets the disabled hover messages for the ' *** controls. ' *** ------------------------------------------------------------------------------ ' *** Sub SetGreyHoverMessage() If NOT DEBUG Then On Error Resume Next Else On Error Goto 0 ' ~~~ Set disabled hover message for the controls document.all("txtAntiVirusScript").title = document.all("lblAVScriptgrey").innerHTML document.all("btnAntiVirusScript").title = document.all("lblAVScriptgrey").innerHTML document.all("txtOtherScript").title = document.all("lblUpdateScriptgrey").innerHTML document.all("btnOtherScript").title = document.all("lblUpdateScriptgrey").innerHTML document.all("spWinUPEnabled").title = document.all("lblWinUPEnabledgrey").innerHTML document.all("spWinUPDisabled").title = document.all("lblWinUPDisabledgrey").innerHTML End Sub ' *** ' *** ------------------------------------------------------------------------------ ' *** Name: FormatScheduleTime() ' *** ------------------------------------------------------------------------------ ' *** Purpose: This is method executed to format the time according ' *** to regional settings. ' *** ------------------------------------------------------------------------------ ' *** Sub FormatScheduleTime() If NOT DEBUG Then On Error Resume Next Else On Error Goto 0 Dim colOptions, oOption, sTime, iPos, sTimeSeparator CONST vbLongTime = 3 sTimeSeparator = ":" Set colOptions = ddSchedule2.Options For Each oOption in colOptions sTime = FormatDateTime(oOption.Text,vbLongTime) If len(sTime) > 8 and InStr(1, sTime, sTimeSeparator) > 0 Then If sTimeSeparator <> " " Then iPos = InStrRev(sTime, sTimeSeparator) Else iPos = InStrRev(sTime, sTimeSeparator) iPos = InStrRev(sTime, sTimeSeparator, iPos-1) End If sTime = Left(sTime, iPos-1) & Mid(sTime, iPos+len(sTimeSeparator)+2 ) Else If len(sTime) <= 8 and InStr(1, sTime, sTimeSeparator) > 0 Then iPos = InStrRev(sTime, sTimeSeparator) sTime = Left(sTime, iPos-1) End If End If ' ~~~ Set the formatted time if proper If len(sTime) <= 12 then oOption.Text = sTime Next End Sub ' *** ' *** ------------------------------------------------------------------------------ ' *** Name: HTAUnLoad() ' *** ------------------------------------------------------------------------------ ' *** Purpose: This method unloads all the objects ' *** created within the scope of the HTA ' *** ------------------------------------------------------------------------------ ' *** Sub HTAUnLoad() If NOT DEBUG Then On Error Resume Next Else On Error Goto 0 Set oDiskProtect = Nothing Set oLog = Nothing End Sub