von Ben » 29.12.2018, 22:53
So mir hat es irgendwie keine Ruhe gelassen das die Suche nach Positivem Download der Datei fortgeführt wird deshalb habe ich weiter Experimentiert, und es geschafft das das Looping gestoppt wird wenn die Datei herunter geladen wurde. Das wollte ich eigentlich schon beim ersten Post so haben da wusste ich nur noch nicht wie das am besten geht. Dank viel googeln habe ich mich etwas weiter Gebildet, und eine für mich passable Lösung gefunden.
Script mit Versionsnummer
Code: Alles auswählen
'vbscript
' I. Atkin & D. Collins 14:35 25/10/2012
' Downloads and executes Microsoft's Malicious Software Removal Tool
' Inspired by Nathan's function http://vbscriptautomation.net/73/download-files-using-vbscript/
' v1.0 Initial release to Symantec Connect
' v1.1 Introduced a loop for major version numbers to give script a longer life and simplifed OS-bit check
' v1.2 Modification by Ben@deskmodder.de:
' - Exe files in x64 AND x86 are downloaded; suitable file is executed; Stops Looping after positive Download
'_______________________________________________________________________________________
' Description
' ===========
' Each month, the filename of the removal tool slightly changes which makes downloading
' a pain. This script downloads all the tools from the download folder using the naming convention
' Windows-KB890830-Vx.y by programatically cycling through the version numbers.
' The last successfully downloaded removal tool is executed.
' Executing this script permits a scripted initiation of the automatic updates process to not require
' the tools download. This bypasses the problems resulting from the automatic updates api continually
' thinking that the tool download is required.
'' Downloads KB890830 to the %temp% folder as KB890830.exe and executes
'' Progress logged to %temp%\KB890830.log
'_______________________________________________________________________________________
Option Explicit
Dim StrURL,StrFullURL,StrFile,StrFullFile,StrLogfile,StrRun,Is32BitOS,StrURL64,StrFullURL64,StrFile64,StrFullFile64,FullFolder64,FullFolder
Dim objShell,strPath,objFSO,objFile,strFolder,hold,hold64
Dim IntMajor,IntMajorMin,IntMajorMax
Dim IntMinor,IntMinorMin,IntMinorMax
Dim i,ret
Dim WshShell
IntMajorMin=5
IntMajorMax=6
IntMinorMin=1
IntMinorMax=100
Set WshShell=CreateObject("WScript.Shell")
Set objShell = CreateObject("Wscript.Shell")
strPath = Wscript.ScriptFullName
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(strPath)
strFolder = objFSO.GetParentFolderName(objFile)
StrFile=wshShell.ExpandEnvironmentStrings(strFolder + "\KB890830-V")
StrLogFile=wshShell.ExpandEnvironmentStrings(strFolder + "\KB890830.Log")
WriteLog("")
WriteLog("Starting KB890830 (Malicious Software Removal Tool) Downloader")
StrURL="http://download.microsoft.com/download/4/a/a/4aa524c6-239d-47ff-860b-5b397199cbf8/Windows-KB890830-V"
WriteLog("URL Root: " & Left(StrURL,InStrRev(StrURL,"/")))
For IntMajor=IntMajorMin to IntMajorMax
For i = IntMinorMin to IntMinorMax
StrFullURL=StrURL & IntMajor & "." & i & ".exe"
StrFullFile=StrFile & IntMajor & "." & i & ".exe"
ret = fDownloadFiles(StrFullURL, StrFullFile)
if ret = 0 then
WriteLog " Successfully downloaded " & Right(StrFullURL,Len(StrFullURL)-InStrRev(StrFullURL,"/")) & " as " & StrFullFile
FullFolder=strFullFile
hold=1
else
if hold = 1 then
exit For
end if
WriteLog " Cannot find " & Right(StrFullURL,Len(StrFullURL)-InStrRev(StrFullURL,"/"))
end if
Next
Next
StrFile64=wshShell.ExpandEnvironmentStrings(strFolder + "\KB890830-x64-V")
WriteLog("")
WriteLog("Starting KB890830 x64 (Malicious Software Removal Tool) Downloader")
StrURL64="http://download.microsoft.com/download/2/C/5/2C563B99-54D9-4D85-A82B-45D3CD2F53CE/Windows-KB890830-x64-V"
For IntMajor=IntMajorMin to IntMajorMax
For i = IntMinorMin to IntMinorMax
StrFullURL64=StrURL64 & IntMajor & "." & i & ".exe"
StrFullFile64=StrFile64 & IntMajor & "." & i & ".exe"
ret = fDownloadFiles(StrFullURL64, StrFullFile64)
if ret = 0 then
WriteLog " Successfully downloaded " & Right(StrFullURL64,Len(StrFullURL64)-InStrRev(StrFullURL64,"/")) & " as " & StrFullFile64
FullFolder64=strFullFile64
hold64=1
else
if hold64 = 1 then
exit For
end if
WriteLog " Cannot find " & Right(StrFullURL64,Len(StrFullURL64)-InStrRev(StrFullURL64,"/"))
end if
Next
Next
'install KB890830
Is32BitOS=(GetObject("winmgmts:root\cimv2:Win32_Processor='cpu0'").AddressWidth = 32)
if Is32BitOS then
dim Folder
Set Folder = CreateObject("WScript.Shell")
ret = Folder.Run ("""" & FullFolder & """" & " -q",1,True)
WriteLog " Install " & Right(FullFolder,Len(FullFolder)-InStrRev(FullFolder,"/"))
else
dim Folder64
Set Folder64 = CreateObject("WScript.Shell")
ret = Folder64.Run ("""" & FullFolder64 & """" & " -q",1,True)
WriteLog " Install " & Right(FullFolder64,Len(FullFolder64)-InStrRev(FullFolder64,"/"))
End if
writeLog "Script Complete"
'download Files
Function fDownloadFiles(sFileURL, sTarget)
Dim temp, objXMLHTTP, objADOStream, fso
Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
'get the remote file
objXMLHTTP.Open "GET", sFileURL, false
'send the request
objXMLHTTP.Send()
'if the data has downloaded sucessfully
If objXMLHTTP.Status = 200 Then
'create binary stream object
Set objADOStream = CreateObject("ADODB.Stream")
objADOStream.Open
'adTypeBinary
objADOStream.Type = 1
objADOStream.Write objXMLHTTP.ResponseBody
'Set the stream position to the start
objADOStream.Position = 0
'create file system object to allow the script to check for an existing file
Set fso = Createobject("Scripting.FileSystemObject")
'check if the file exists, if it exists then delete it
If fso.FileExists(sTarget) Then fso.DeleteFile sTarget
'destroy file system object
Set fso = Nothing
'save the ado stream to a file
objADOStream.SaveToFile sTarget
'close the ado stream
objADOStream.Close
'destroy the ado stream object
Set objADOStream = Nothing
temp = 0
Else
temp = 1
End If
'destroy xml http object
Set objXMLHTTP = Nothing
fDownloadFiles = temp
End function
Sub WriteLog(sTxt)
'Uses strLogfile
Dim sLogFile, fso, ts
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile(StrLogFile, 8, True)
ts.WriteLine Now() & " - " & sTxt
ts.close
Set ts = Nothing
Set fso = Nothing
End Sub
Script ohne Versionsnummer
Code: Alles auswählen
'vbscript
' I. Atkin & D. Collins 14:35 25/10/2012
' Downloads and executes Microsoft's Malicious Software Removal Tool
' Inspired by Nathan's function http://vbscriptautomation.net/73/download-files-using-vbscript/
' v1.0 Initial release to Symantec Connect
' v1.1 Introduced a loop for major version numbers to give script a longer life and simplifed OS-bit check
' v1.2 Modification by Ben@deskmodder.de:
' - Exe files in x64 AND x86 are downloaded; suitable file is executed; Stops Looping after positive Download
'_______________________________________________________________________________________
' Description
' ===========
' Each month, the filename of the removal tool slightly changes which makes downloading
' a pain. This script downloads all the tools from the download folder using the naming convention
' Windows-KB890830-Vx.y by programatically cycling through the version numbers.
' The last successfully downloaded removal tool is executed.
' Executing this script permits a scripted initiation of the automatic updates process to not require
' the tools download. This bypasses the problems resulting from the automatic updates api continually
' thinking that the tool download is required.
'' Downloads KB890830 to the %temp% folder as KB890830.exe and executes
'' Progress logged to %temp%\KB890830.log
'_______________________________________________________________________________________
Option Explicit
Dim StrURL,StrFullURL,StrFile,StrLogfile,StrRun,Is32BitOS,StrURL64,StrFullURL64,StrFile64,FullFolder64,FullFolder
Dim objShell,strPath,objFSO,objFile,strFolder,hold,hold64
Dim IntMajor,IntMajorMin,IntMajorMax
Dim IntMinor,IntMinorMin,IntMinorMax
Dim i,ret
Dim WshShell
IntMajorMin=5
IntMajorMax=6
IntMinorMin=1
IntMinorMax=100
Set WshShell=CreateObject("WScript.Shell")
Set objShell = CreateObject("Wscript.Shell")
strPath = Wscript.ScriptFullName
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(strPath)
strFolder = objFSO.GetParentFolderName(objFile)
StrFile=wshShell.ExpandEnvironmentStrings(strFolder + "\KB890830.exe")
StrLogFile=wshShell.ExpandEnvironmentStrings(strFolder + "\KB890830.Log")
WriteLog("")
WriteLog("Starting KB890830 (Malicious Software Removal Tool) Downloader")
StrURL="http://download.microsoft.com/download/4/a/a/4aa524c6-239d-47ff-860b-5b397199cbf8/Windows-KB890830-V"
WriteLog("URL Root: " & Left(StrURL,InStrRev(StrURL,"/")))
For IntMajor=IntMajorMin to IntMajorMax
For i = IntMinorMin to IntMinorMax
StrFullURL=StrURL & IntMajor & "." & i & ".exe"
ret = fDownloadFiles(StrFullURL, StrFile)
if ret = 0 then
WriteLog " Successfully downloaded " & Right(StrFullURL,Len(StrFullURL)-InStrRev(StrFullURL,"/")) & " as " & StrFile
FullFolder=strFile
hold=1
else
if hold = 1 then
exit For
end if
WriteLog " Cannot find " & Right(StrFullURL,Len(StrFullURL)-InStrRev(StrFullURL,"/"))
end if
Next
Next
StrFile64=wshShell.ExpandEnvironmentStrings(strFolder + "\KB890830-x64.exe")
WriteLog("")
WriteLog("Starting KB890830 x64 (Malicious Software Removal Tool) Downloader")
StrURL64="http://download.microsoft.com/download/2/C/5/2C563B99-54D9-4D85-A82B-45D3CD2F53CE/Windows-KB890830-x64-V"
For IntMajor=IntMajorMin to IntMajorMax
For i = IntMinorMin to IntMinorMax
StrFullURL64=StrURL64 & IntMajor & "." & i & ".exe"
ret = fDownloadFiles(StrFullURL64, StrFile64)
if ret = 0 then
WriteLog " Successfully downloaded " & Right(StrFullURL64,Len(StrFullURL64)-InStrRev(StrFullURL64,"/")) & " as " & StrFile64
FullFolder64=strFile64
hold64=1
else
if hold64 = 1 then
exit For
end if
WriteLog " Cannot find " & Right(StrFullURL64,Len(StrFullURL64)-InStrRev(StrFullURL64,"/"))
end if
Next
Next
'install KB890830
Is32BitOS=(GetObject("winmgmts:root\cimv2:Win32_Processor='cpu0'").AddressWidth = 32)
if Is32BitOS then
dim Folder
Set Folder = CreateObject("WScript.Shell")
ret = Folder.Run ("""" & FullFolder & """" & " -q",1,True)
WriteLog " Install " & Right(FullFolder,Len(FullFolder)-InStrRev(FullFolder,"/"))
else
dim Folder64
Set Folder64 = CreateObject("WScript.Shell")
ret = Folder64.Run ("""" & FullFolder64 & """" & " -q",1,True)
WriteLog " Install " & Right(FullFolder64,Len(FullFolder64)-InStrRev(FullFolder64,"/"))
End if
writeLog "Script Complete"
'download Files
Function fDownloadFiles(sFileURL, sTarget)
Dim temp, objXMLHTTP, objADOStream, fso
Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
'get the remote file
objXMLHTTP.Open "GET", sFileURL, false
'send the request
objXMLHTTP.Send()
'if the data has downloaded sucessfully
If objXMLHTTP.Status = 200 Then
'create binary stream object
Set objADOStream = CreateObject("ADODB.Stream")
objADOStream.Open
'adTypeBinary
objADOStream.Type = 1
objADOStream.Write objXMLHTTP.ResponseBody
'Set the stream position to the start
objADOStream.Position = 0
'create file system object to allow the script to check for an existing file
Set fso = Createobject("Scripting.FileSystemObject")
'check if the file exists, if it exists then delete it
If fso.FileExists(sTarget) Then fso.DeleteFile sTarget
'destroy file system object
Set fso = Nothing
'save the ado stream to a file
objADOStream.SaveToFile sTarget
'close the ado stream
objADOStream.Close
'destroy the ado stream object
Set objADOStream = Nothing
temp = 0
Else
temp = 1
End If
'destroy xml http object
Set objXMLHTTP = Nothing
fDownloadFiles = temp
End function
Sub WriteLog(sTxt)
'Uses strLogfile
Dim sLogFile, fso, ts
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile(StrLogFile, 8, True)
ts.WriteLine Now() & " - " & sTxt
ts.close
Set ts = Nothing
Set fso = Nothing
End Sub
Gruß, Ben
So mir hat es irgendwie keine Ruhe gelassen das die Suche nach Positivem Download der Datei fortgeführt wird deshalb habe ich weiter Experimentiert, und es geschafft das das Looping gestoppt wird wenn die Datei herunter geladen wurde. Das wollte ich eigentlich schon beim ersten Post so haben da wusste ich nur noch nicht wie das am besten geht. Dank viel googeln habe ich mich etwas weiter Gebildet, und eine für mich passable Lösung gefunden.
Script mit Versionsnummer
[code]'vbscript
' I. Atkin & D. Collins 14:35 25/10/2012
' Downloads and executes Microsoft's Malicious Software Removal Tool
' Inspired by Nathan's function http://vbscriptautomation.net/73/download-files-using-vbscript/
' v1.0 Initial release to Symantec Connect
' v1.1 Introduced a loop for major version numbers to give script a longer life and simplifed OS-bit check
' v1.2 Modification by Ben@deskmodder.de:
' - Exe files in x64 AND x86 are downloaded; suitable file is executed; Stops Looping after positive Download
'_______________________________________________________________________________________
' Description
' ===========
' Each month, the filename of the removal tool slightly changes which makes downloading
' a pain. This script downloads all the tools from the download folder using the naming convention
' Windows-KB890830-Vx.y by programatically cycling through the version numbers.
' The last successfully downloaded removal tool is executed.
' Executing this script permits a scripted initiation of the automatic updates process to not require
' the tools download. This bypasses the problems resulting from the automatic updates api continually
' thinking that the tool download is required.
'' Downloads KB890830 to the %temp% folder as KB890830.exe and executes
'' Progress logged to %temp%\KB890830.log
'_______________________________________________________________________________________
Option Explicit
Dim StrURL,StrFullURL,StrFile,StrFullFile,StrLogfile,StrRun,Is32BitOS,StrURL64,StrFullURL64,StrFile64,StrFullFile64,FullFolder64,FullFolder
Dim objShell,strPath,objFSO,objFile,strFolder,hold,hold64
Dim IntMajor,IntMajorMin,IntMajorMax
Dim IntMinor,IntMinorMin,IntMinorMax
Dim i,ret
Dim WshShell
IntMajorMin=5
IntMajorMax=6
IntMinorMin=1
IntMinorMax=100
Set WshShell=CreateObject("WScript.Shell")
Set objShell = CreateObject("Wscript.Shell")
strPath = Wscript.ScriptFullName
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(strPath)
strFolder = objFSO.GetParentFolderName(objFile)
StrFile=wshShell.ExpandEnvironmentStrings(strFolder + "\KB890830-V")
StrLogFile=wshShell.ExpandEnvironmentStrings(strFolder + "\KB890830.Log")
WriteLog("")
WriteLog("Starting KB890830 (Malicious Software Removal Tool) Downloader")
StrURL="http://download.microsoft.com/download/4/a/a/4aa524c6-239d-47ff-860b-5b397199cbf8/Windows-KB890830-V"
WriteLog("URL Root: " & Left(StrURL,InStrRev(StrURL,"/")))
For IntMajor=IntMajorMin to IntMajorMax
For i = IntMinorMin to IntMinorMax
StrFullURL=StrURL & IntMajor & "." & i & ".exe"
StrFullFile=StrFile & IntMajor & "." & i & ".exe"
ret = fDownloadFiles(StrFullURL, StrFullFile)
if ret = 0 then
WriteLog " Successfully downloaded " & Right(StrFullURL,Len(StrFullURL)-InStrRev(StrFullURL,"/")) & " as " & StrFullFile
FullFolder=strFullFile
hold=1
else
if hold = 1 then
exit For
end if
WriteLog " Cannot find " & Right(StrFullURL,Len(StrFullURL)-InStrRev(StrFullURL,"/"))
end if
Next
Next
StrFile64=wshShell.ExpandEnvironmentStrings(strFolder + "\KB890830-x64-V")
WriteLog("")
WriteLog("Starting KB890830 x64 (Malicious Software Removal Tool) Downloader")
StrURL64="http://download.microsoft.com/download/2/C/5/2C563B99-54D9-4D85-A82B-45D3CD2F53CE/Windows-KB890830-x64-V"
For IntMajor=IntMajorMin to IntMajorMax
For i = IntMinorMin to IntMinorMax
StrFullURL64=StrURL64 & IntMajor & "." & i & ".exe"
StrFullFile64=StrFile64 & IntMajor & "." & i & ".exe"
ret = fDownloadFiles(StrFullURL64, StrFullFile64)
if ret = 0 then
WriteLog " Successfully downloaded " & Right(StrFullURL64,Len(StrFullURL64)-InStrRev(StrFullURL64,"/")) & " as " & StrFullFile64
FullFolder64=strFullFile64
hold64=1
else
if hold64 = 1 then
exit For
end if
WriteLog " Cannot find " & Right(StrFullURL64,Len(StrFullURL64)-InStrRev(StrFullURL64,"/"))
end if
Next
Next
'install KB890830
Is32BitOS=(GetObject("winmgmts:root\cimv2:Win32_Processor='cpu0'").AddressWidth = 32)
if Is32BitOS then
dim Folder
Set Folder = CreateObject("WScript.Shell")
ret = Folder.Run ("""" & FullFolder & """" & " -q",1,True)
WriteLog " Install " & Right(FullFolder,Len(FullFolder)-InStrRev(FullFolder,"/"))
else
dim Folder64
Set Folder64 = CreateObject("WScript.Shell")
ret = Folder64.Run ("""" & FullFolder64 & """" & " -q",1,True)
WriteLog " Install " & Right(FullFolder64,Len(FullFolder64)-InStrRev(FullFolder64,"/"))
End if
writeLog "Script Complete"
'download Files
Function fDownloadFiles(sFileURL, sTarget)
Dim temp, objXMLHTTP, objADOStream, fso
Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
'get the remote file
objXMLHTTP.Open "GET", sFileURL, false
'send the request
objXMLHTTP.Send()
'if the data has downloaded sucessfully
If objXMLHTTP.Status = 200 Then
'create binary stream object
Set objADOStream = CreateObject("ADODB.Stream")
objADOStream.Open
'adTypeBinary
objADOStream.Type = 1
objADOStream.Write objXMLHTTP.ResponseBody
'Set the stream position to the start
objADOStream.Position = 0
'create file system object to allow the script to check for an existing file
Set fso = Createobject("Scripting.FileSystemObject")
'check if the file exists, if it exists then delete it
If fso.FileExists(sTarget) Then fso.DeleteFile sTarget
'destroy file system object
Set fso = Nothing
'save the ado stream to a file
objADOStream.SaveToFile sTarget
'close the ado stream
objADOStream.Close
'destroy the ado stream object
Set objADOStream = Nothing
temp = 0
Else
temp = 1
End If
'destroy xml http object
Set objXMLHTTP = Nothing
fDownloadFiles = temp
End function
Sub WriteLog(sTxt)
'Uses strLogfile
Dim sLogFile, fso, ts
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile(StrLogFile, 8, True)
ts.WriteLine Now() & " - " & sTxt
ts.close
Set ts = Nothing
Set fso = Nothing
End Sub
[/code]
Script ohne Versionsnummer
[code]'vbscript
' I. Atkin & D. Collins 14:35 25/10/2012
' Downloads and executes Microsoft's Malicious Software Removal Tool
' Inspired by Nathan's function http://vbscriptautomation.net/73/download-files-using-vbscript/
' v1.0 Initial release to Symantec Connect
' v1.1 Introduced a loop for major version numbers to give script a longer life and simplifed OS-bit check
' v1.2 Modification by Ben@deskmodder.de:
' - Exe files in x64 AND x86 are downloaded; suitable file is executed; Stops Looping after positive Download
'_______________________________________________________________________________________
' Description
' ===========
' Each month, the filename of the removal tool slightly changes which makes downloading
' a pain. This script downloads all the tools from the download folder using the naming convention
' Windows-KB890830-Vx.y by programatically cycling through the version numbers.
' The last successfully downloaded removal tool is executed.
' Executing this script permits a scripted initiation of the automatic updates process to not require
' the tools download. This bypasses the problems resulting from the automatic updates api continually
' thinking that the tool download is required.
'' Downloads KB890830 to the %temp% folder as KB890830.exe and executes
'' Progress logged to %temp%\KB890830.log
'_______________________________________________________________________________________
Option Explicit
Dim StrURL,StrFullURL,StrFile,StrLogfile,StrRun,Is32BitOS,StrURL64,StrFullURL64,StrFile64,FullFolder64,FullFolder
Dim objShell,strPath,objFSO,objFile,strFolder,hold,hold64
Dim IntMajor,IntMajorMin,IntMajorMax
Dim IntMinor,IntMinorMin,IntMinorMax
Dim i,ret
Dim WshShell
IntMajorMin=5
IntMajorMax=6
IntMinorMin=1
IntMinorMax=100
Set WshShell=CreateObject("WScript.Shell")
Set objShell = CreateObject("Wscript.Shell")
strPath = Wscript.ScriptFullName
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(strPath)
strFolder = objFSO.GetParentFolderName(objFile)
StrFile=wshShell.ExpandEnvironmentStrings(strFolder + "\KB890830.exe")
StrLogFile=wshShell.ExpandEnvironmentStrings(strFolder + "\KB890830.Log")
WriteLog("")
WriteLog("Starting KB890830 (Malicious Software Removal Tool) Downloader")
StrURL="http://download.microsoft.com/download/4/a/a/4aa524c6-239d-47ff-860b-5b397199cbf8/Windows-KB890830-V"
WriteLog("URL Root: " & Left(StrURL,InStrRev(StrURL,"/")))
For IntMajor=IntMajorMin to IntMajorMax
For i = IntMinorMin to IntMinorMax
StrFullURL=StrURL & IntMajor & "." & i & ".exe"
ret = fDownloadFiles(StrFullURL, StrFile)
if ret = 0 then
WriteLog " Successfully downloaded " & Right(StrFullURL,Len(StrFullURL)-InStrRev(StrFullURL,"/")) & " as " & StrFile
FullFolder=strFile
hold=1
else
if hold = 1 then
exit For
end if
WriteLog " Cannot find " & Right(StrFullURL,Len(StrFullURL)-InStrRev(StrFullURL,"/"))
end if
Next
Next
StrFile64=wshShell.ExpandEnvironmentStrings(strFolder + "\KB890830-x64.exe")
WriteLog("")
WriteLog("Starting KB890830 x64 (Malicious Software Removal Tool) Downloader")
StrURL64="http://download.microsoft.com/download/2/C/5/2C563B99-54D9-4D85-A82B-45D3CD2F53CE/Windows-KB890830-x64-V"
For IntMajor=IntMajorMin to IntMajorMax
For i = IntMinorMin to IntMinorMax
StrFullURL64=StrURL64 & IntMajor & "." & i & ".exe"
ret = fDownloadFiles(StrFullURL64, StrFile64)
if ret = 0 then
WriteLog " Successfully downloaded " & Right(StrFullURL64,Len(StrFullURL64)-InStrRev(StrFullURL64,"/")) & " as " & StrFile64
FullFolder64=strFile64
hold64=1
else
if hold64 = 1 then
exit For
end if
WriteLog " Cannot find " & Right(StrFullURL64,Len(StrFullURL64)-InStrRev(StrFullURL64,"/"))
end if
Next
Next
'install KB890830
Is32BitOS=(GetObject("winmgmts:root\cimv2:Win32_Processor='cpu0'").AddressWidth = 32)
if Is32BitOS then
dim Folder
Set Folder = CreateObject("WScript.Shell")
ret = Folder.Run ("""" & FullFolder & """" & " -q",1,True)
WriteLog " Install " & Right(FullFolder,Len(FullFolder)-InStrRev(FullFolder,"/"))
else
dim Folder64
Set Folder64 = CreateObject("WScript.Shell")
ret = Folder64.Run ("""" & FullFolder64 & """" & " -q",1,True)
WriteLog " Install " & Right(FullFolder64,Len(FullFolder64)-InStrRev(FullFolder64,"/"))
End if
writeLog "Script Complete"
'download Files
Function fDownloadFiles(sFileURL, sTarget)
Dim temp, objXMLHTTP, objADOStream, fso
Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
'get the remote file
objXMLHTTP.Open "GET", sFileURL, false
'send the request
objXMLHTTP.Send()
'if the data has downloaded sucessfully
If objXMLHTTP.Status = 200 Then
'create binary stream object
Set objADOStream = CreateObject("ADODB.Stream")
objADOStream.Open
'adTypeBinary
objADOStream.Type = 1
objADOStream.Write objXMLHTTP.ResponseBody
'Set the stream position to the start
objADOStream.Position = 0
'create file system object to allow the script to check for an existing file
Set fso = Createobject("Scripting.FileSystemObject")
'check if the file exists, if it exists then delete it
If fso.FileExists(sTarget) Then fso.DeleteFile sTarget
'destroy file system object
Set fso = Nothing
'save the ado stream to a file
objADOStream.SaveToFile sTarget
'close the ado stream
objADOStream.Close
'destroy the ado stream object
Set objADOStream = Nothing
temp = 0
Else
temp = 1
End If
'destroy xml http object
Set objXMLHTTP = Nothing
fDownloadFiles = temp
End function
Sub WriteLog(sTxt)
'Uses strLogfile
Dim sLogFile, fso, ts
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile(StrLogFile, 8, True)
ts.WriteLine Now() & " - " & sTxt
ts.close
Set ts = Nothing
Set fso = Nothing
End Sub
[/code]
Gruß, Ben