    sTarget = "C:\temp"


    Set objFSO = CreateObject("Scripting.FileSystemObject")
    If Not objFSO.FolderExists(sTarget) Then
    	objFSO.CreateFolder("c:\temp") 
    End If


 

    strFileURL = "http://www.backupassist.com/downloads/releases/latest/BackupAssistV5.msi"
    strHDLocation = "c:\temp\BackupAssistV5.msi"

 

    Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
 
    objXMLHTTP.open "GET", strFileURL, false
    objXMLHTTP.send()
 
    If objXMLHTTP.Status = 200 Then
      
      WScript.StdOut.Write "Downloading the latest version of BackupAssist..." & VbCrLf & VbCrLf
      Set objADOStream = CreateObject("ADODB.Stream")
      objADOStream.Open
      objADOStream.Type = 1 'adTypeBinary
 
      objADOStream.Write objXMLHTTP.ResponseBody
      objADOStream.Position = 0    
 
      Set objFSO = Createobject("Scripting.FileSystemObject")
      If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
      Set objFSO = Nothing
      
      objADOStream.SaveToFile strHDLocation
      objADOStream.Close
      WScript.StdOut.Write "Download complete" & VbCrLf & VbCrLf      
      Set objADOStream = Nothing
    End if


    Dim installer
    Set installer = CreateObject("WindowsInstaller.Installer")
    strTempProdCode = ""
    For Each strProductCode In installer.Products

    	If installer.ProductInfo(strProductCode, "InstalledProductName") = "BackupAssist v5" Then

        	strTempProdCode = strProductCode
    	End If

    Next




    set fso = Wscript.CreateObject("Scripting.FileSystemObject")



If Not strTempProdCode = "" Then


    If fso.FileExists("C:\Temp\BackupAssistV5.msi") Then

        strTemp = strTempProdCode & " /passive"
        strTemp2 = strHDLocation & " /passive /qb IE5FOUND=1"
     
        Dim objShell
        Set objShell = CreateObject("WScript.Shell")
        objShell.Run "%comspec% /c msiexec /x " & strTemp _
        & "& msiexec /package " & strTemp
    	WScript.StdOut.Write"Automated update was successful"
        WScript.Quit 
	
	
    Else WScript.StdOut.Write"The BackupAssist update did not download. The automated update was unsuccessful"

    End If


Else
    WScript.StdOut.Write "BackupAssist is not currently installed on this machine!"& VbCrLf &"Automatic updating not available!" & VbCrLf & VbCrLf

End If





