vbs script für download von MSRT (Malicious Software Removal Tool) - Anpassung & Hilfe nötig

Deine Frage passt nicht in die anderen Bereiche, dann stelle sie hier.
Benutzeravatar
Holgi
Elite
Elite
Beiträge: 2190
Registriert: 12.05.2018, 12:33
Hat sich bedankt: 225 Mal
Danke erhalten: 302 Mal
Gender:

vbs script für download von MSRT (Malicious Software Removal Tool) - Anpassung & Hilfe nötig

Beitrag von Holgi » 28.12.2018, 16:13

Hallo liebe Deskmodder,

Problem:
benötigt wird ein Script (Vbs, CMD-Batch..) welches mir auf Anforderung die neueste Version der KB890830 (X64/X86) herunterlädt.
Da es keinen feststehenden Namen hierfür gibt, weil im Namen immer die aktuelle Version angehängt ist (z.B. Windows-KB890830-x64-V5.67.exe, nächsten Monat womöglich Windows-KB890830-x64-V5.68.exe usw.) muss hier entsprechend getrickst werden.
Im Netz habe ich bereits ein funktionierendes vbs-Script gefunden, aber es erfüllt nicht ganz meine Anforderungen.
Das existierende Script prüft, ob es sich auf einem 64-bit Betriebssystem befindet, oder einem X86-Rechner und lädt dann nur die hierfür erforderliche Datei herunter. Darüberhinaus wird die Datei im Ordner (appdata/local/temp) gespeichert.
Ich hingegen würde es begrüßen, wenn beide Versionen des Tools heruntergeladen werden und dazu noch im gleichen Ordner, wo das Script ausgeführt wird (also z.B. %homepath%\downloads\MSRT). Er bei der Installation sollte dann das Script prüfen, ob die X64 oder die X86-Version benötigt wird.
Kennt sich jemand mit vbs aus und kann das Script entsprechend anpassen; oder hat jemand eine noch elegantere Lösung parat?
Hier die links zu der existierenden Lösung:
https://www.symantec.com/connect/downlo ... moval-tool
https://www.symantec.com/connect/sites/ ... 1.vbs_.txt

euch allen schon mal einen guten Rutsch ins Jahr 2019
PDF24 angepasste Installation (nur PDF Druckertreiber) per Script: viewtopic.php?t=30284
Winget (Desktop App Installer) für Windows Versionen ohne Store installieren (HowTo): viewtopic.php?t=26214
Vorstellung: tiny11builder; Script zur Verschlankung von Windows 11: viewtopic.php?t=30134
Windows StartMenü Empfohlen (Recommended Section) komplett ausblenden: viewtopic.php?t=30574
Hyper-V VM per Script erstellen viewtopic.php?t=25114

Tante Google

vbs script für download von MSRT (Malicious Software Removal Tool) - Anpassung & Hilfe nötig

Beitrag von Tante Google » 28.12.2018, 16:13


Benutzeravatar
Ben
★ Team Blog ★
Beiträge: 1004
Registriert: 28.12.2017, 15:19
Hat sich bedankt: 42 Mal
Danke erhalten: 73 Mal
Gender:

Re: vbs script für download von MSRT (Malicious Software Removal Tool) - Anpassung & Hilfe nötig

Beitrag von Ben » 29.12.2018, 13:06

Hallo Holgi
Ich habe mal mit dem vbs Script herum gespielt obwohl ich nichts davon verstehe. Aber mir ist es gelungen beide Dateien in den Ordner wo das Script ausgeführt wird zu downloaden und danach das MSRT passend zu dem installierten Betriebssystem ob jetzt ein 32Bit oder 64Bit installieren lassen.

Habe zwei Scripte erstellt eines mit der Versionsnummer im Dateinamen und eines ohne die Versionsnummer.

Hier 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


'_______________________________________________________________________________________
' 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
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
      else
        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
      else
        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
Hier 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


'_______________________________________________________________________________________
' 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
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
      else
        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
      else
        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
Habe die Scripte auch in der Zip Datei mit angehängt

Gruß Ben
Du hast keine ausreichende Berechtigung, um die Dateianhänge dieses Beitrags anzusehen.

Benutzeravatar
Holgi
Elite
Elite
Beiträge: 2190
Registriert: 12.05.2018, 12:33
Hat sich bedankt: 225 Mal
Danke erhalten: 302 Mal
Gender:

Re: vbs script für download von MSRT (Malicious Software Removal Tool) - Anpassung & Hilfe nötig

Beitrag von Holgi » 29.12.2018, 13:47

Danke Ben! Tausend Dank! :dankeschoen:
Beide Scripte funktionieren super!
Beide haben auch ihren eigenen Charme; ich weiß, noch nicht, ob ich das mit ohne das ohne Versionesnummer weiternutzen werde.
Nochmals vielen, vielen Dank.
PDF24 angepasste Installation (nur PDF Druckertreiber) per Script: viewtopic.php?t=30284
Winget (Desktop App Installer) für Windows Versionen ohne Store installieren (HowTo): viewtopic.php?t=26214
Vorstellung: tiny11builder; Script zur Verschlankung von Windows 11: viewtopic.php?t=30134
Windows StartMenü Empfohlen (Recommended Section) komplett ausblenden: viewtopic.php?t=30574
Hyper-V VM per Script erstellen viewtopic.php?t=25114

Benutzeravatar
Holgi
Elite
Elite
Beiträge: 2190
Registriert: 12.05.2018, 12:33
Hat sich bedankt: 225 Mal
Danke erhalten: 302 Mal
Gender:

Re: vbs script für download von MSRT (Malicious Software Removal Tool) - Anpassung & Hilfe nötig

Beitrag von Holgi » 29.12.2018, 13:54

BTW:
kannst du mal hier vorbeischauen:
https://www.win-unattended.de/viewtopic ... c557fd59df
letzte Beiträge. Danke!
PDF24 angepasste Installation (nur PDF Druckertreiber) per Script: viewtopic.php?t=30284
Winget (Desktop App Installer) für Windows Versionen ohne Store installieren (HowTo): viewtopic.php?t=26214
Vorstellung: tiny11builder; Script zur Verschlankung von Windows 11: viewtopic.php?t=30134
Windows StartMenü Empfohlen (Recommended Section) komplett ausblenden: viewtopic.php?t=30574
Hyper-V VM per Script erstellen viewtopic.php?t=25114

Benutzeravatar
Nemo_G
Profi
Profi
Beiträge: 177
Registriert: 10.05.2014, 10:09
Hat sich bedankt: 2 Mal
Gender:

Re: vbs script für download von MSRT (Malicious Software Removal Tool) - Anpassung & Hilfe nötig

Beitrag von Nemo_G » 29.12.2018, 14:52

Holgi hat geschrieben: 29.12.2018, 13:54... https://www.win-unattended.de/viewtopic ... c557fd59df ...
Hallo Ben,
Hier der direkte Link zu Holgis anderer Baustelle in Sachen Defender. Ich war daraufhin so frei, Dich ins Spiel zu bringen ...

Nun aber wieder zum Thema:
Ich habe mich für das zweite Skript entschieden, da es die EXEn (ohne Versions-Nr) bei späteren Versionen überschreibt.
Es ist auch bei mir zufriedenstellend durchgelaufen.
Kleine Änderungen habe ich --- ebenfalls ohne Kenntnis von VB --- für mich eingebracht:
  • Nun mal nicht so schüchtern mit Deinem Beitrag zum Problem:

    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.2 Modification by Ben@deskmodder.de: 
    '     - Exe files in x64 AND x86 are downloaded; suitable file is executed
    ' v1.1 Introduced a loop for major version numbers to give script a longer life and simplifed OS-bit check
    ' v1.0 Initial release to Symantec Connect
    ...
    
  • (Neue) Zeile 40: Änderung auf IntMajorMax=5 verkürzt die Durchsucherei. Bis MS auf v6.xx geht, haben wir noch fast drei Jahre Zeit.
  • (Neue) Zeile 42: Änderung auf IntMinorMin=67 (für die aktuelle Version v5.67) verkürzt die Durchsucherei. Bis MS auf über v5.100 geht, haben wir noch fast drei Jahre Zeit.
Bislang habe ich das letzte KB890830 immer in der ISO hinterlegt.
Nun kann ich per <iso>\Sources\$OEM$\E\I\OS_UPD\KB890830\KB890830.VBS das Skript gleich an der für mich geeigneten Position auf Laufwerk D: des Zielrechners hinterlegen.

Gruß, Nemo
Zuletzt geändert von Nemo_G am 29.12.2018, 21:46, insgesamt 1-mal geändert.
Lizenzfrage: Die deutsche Rechtschreibung ist Freeware; jeder darf sie nutzen.
Sie ist aber nicht OpenSource; das heißt, der Nutzer darf sie nicht verändern!

Benutzeravatar
Ben
★ Team Blog ★
Beiträge: 1004
Registriert: 28.12.2017, 15:19
Hat sich bedankt: 42 Mal
Danke erhalten: 73 Mal
Gender:

Re: vbs script für download von MSRT (Malicious Software Removal Tool) - Anpassung & Hilfe nötig

Beitrag von Ben » 29.12.2018, 21:08

Hallo Holgi
Wolltest du die aktuellen links für die KB4052623 die hätte ich hier.

Code: Alles auswählen

[ Update für Windows Defender Antivirus-Antischadsoftwareplattform – KB4052623 (Version 4.18.1812.3) ]
x86
http://download.windowsupdate.com/d/msdownload/update/software/defu/2018/11/updateplatform_0b1fde6c65ab53f5747775ad94e6a8ed8102d7a8.exe 
amd64
http://download.windowsupdate.com/d/msdownload/update/software/defu/2018/11/updateplatform_e7096e1dcdc873d714789448002af76e0960692c.exe

Gruß, Ben

PS: Einen guten Rutsch ins neue Jahr!

Benutzeravatar
Nemo_G
Profi
Profi
Beiträge: 177
Registriert: 10.05.2014, 10:09
Hat sich bedankt: 2 Mal
Gender:

Re: vbs script für download von MSRT (Malicious Software Removal Tool) - Anpassung & Hilfe nötig

Beitrag von Nemo_G » 29.12.2018, 21:23

Zwar heiße ich nicht Holgi, aber ich danke Dir ganz herzlich, dass Du die Dateien herausgesucht hast!

Credits für Dich bei Win-Unattended!

Zusatzfrage:
Ändern die sich häufig / monatlich?

Gruß, Nemo

PS:
Auch Dir einen Guten Rutsch nach 2019 (aber bitte nicht auf Glatteis!)
Zuletzt geändert von Nemo_G am 30.12.2018, 11:27, insgesamt 1-mal geändert.
Lizenzfrage: Die deutsche Rechtschreibung ist Freeware; jeder darf sie nutzen.
Sie ist aber nicht OpenSource; das heißt, der Nutzer darf sie nicht verändern!

Benutzeravatar
Ben
★ Team Blog ★
Beiträge: 1004
Registriert: 28.12.2017, 15:19
Hat sich bedankt: 42 Mal
Danke erhalten: 73 Mal
Gender:

Re: vbs script für download von MSRT (Malicious Software Removal Tool) - Anpassung & Hilfe nötig

Beitrag von Ben » 29.12.2018, 22:05

Nemo_G hat geschrieben: 29.12.2018, 21:23 Zusatzfrage:
Ändern die sich häufig / monatlich?
Auf diese Frage habe ich leider keine Eindeutige Antwort ist unterschiedlich. Dieses Update kommt halt ab und zu mit denn Normalen Defender Updates, und meist bekommt man davon auch nichts mit. Außer man führt das Windows Update mal von Hand aus, aber da ist es meist auch nur kurz zu sehen wenn es installiert wird.

Gruß, Ben

Benutzeravatar
Ben
★ Team Blog ★
Beiträge: 1004
Registriert: 28.12.2017, 15:19
Hat sich bedankt: 42 Mal
Danke erhalten: 73 Mal
Gender:

Re: vbs script für download von MSRT (Malicious Software Removal Tool) - Anpassung & Hilfe nötig

Beitrag 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
Du hast keine ausreichende Berechtigung, um die Dateianhänge dieses Beitrags anzusehen.

Benutzeravatar
Holgi
Elite
Elite
Beiträge: 2190
Registriert: 12.05.2018, 12:33
Hat sich bedankt: 225 Mal
Danke erhalten: 302 Mal
Gender:

Re: vbs script für download von MSRT (Malicious Software Removal Tool) - Anpassung & Hilfe nötig

Beitrag von Holgi » 30.12.2018, 14:48

Danke Ben für die Bereitstellung der Download-Links von Windows Defender Antivirus-Antischadsoftwareplattform – KB4052623.
Magst du vlt. noch mitteilen, wie man immer an die aktuelle Version herankommen kann?
Gibt es da ein paar Google Suchwörter, die einen auf die entsprechenden Links verweisen?
Ich nehme mal an, das dies kein statischer Link ist und für die nächste Version von KB4052623 nicht mehr funktionieren wird, oder?
Schöner wäre natürlich ein ähnliches Script wie zu den Defender Updates oder MSRT (KB890830). :smile:
PDF24 angepasste Installation (nur PDF Druckertreiber) per Script: viewtopic.php?t=30284
Winget (Desktop App Installer) für Windows Versionen ohne Store installieren (HowTo): viewtopic.php?t=26214
Vorstellung: tiny11builder; Script zur Verschlankung von Windows 11: viewtopic.php?t=30134
Windows StartMenü Empfohlen (Recommended Section) komplett ausblenden: viewtopic.php?t=30574
Hyper-V VM per Script erstellen viewtopic.php?t=25114

Benutzeravatar
Ben
★ Team Blog ★
Beiträge: 1004
Registriert: 28.12.2017, 15:19
Hat sich bedankt: 42 Mal
Danke erhalten: 73 Mal
Gender:

Re: vbs script für download von MSRT (Malicious Software Removal Tool) - Anpassung & Hilfe nötig

Beitrag von Ben » 30.12.2018, 15:24

Hallo Holgi
Die Links für die KB4052623 kann man sich mit diesem Tool anzeigen lassen muss aber jeweils auf einem 32Bit und auf einem 64Bit Windows 10 ausgeführt werden, da nur die Links für die jeweilige Architektur angezeigt werden. Dazu einmal mit dem Tool nach Updates suchen lassen, entweder es ist noch nicht installiert dann erscheint es unter "Windows Update" oder wenn es bereits installiert ist steht es unter "Installed Updates". Da dann das Kontrollkästchen vor dem Update anklicken das es markiert ist, und anschließend auf das Ketten-Symbol um den Link in die Zwischenablage zu kopieren. Jetzt kann man das aus der Zwischenablage in einem Editor einfügen und man sieht den aktuellen Link zu der Datei.
https://www.deskmodder.de/blog/2018/11/ ... tallieren/

Wenn man das mit einem Script machen wollte. Würde das zu aufwendig werden, da dabei zu viele Variablen vorkommen.

/d/msdownload/update/software/defu/2018/11/updateplatform_0b1fde6c65ab53f5747775ad94e6a8ed8102d7a8.exe

Die Farblich markierten Stellen Varieren. Das "d" kann auch ein "c" sein.
die 2018 kann 2019, 2020 etc. sein, die 11 je nach Monat eine 01, 02, 03 - 12 sein.
Und von dem 40 stelligen Hashwert ganz zu schweigen da gibt es zu viele Möglichkeiten für.

Und einen Statischen Link dafür habe ich auch noch keinen gefunden, wird es also nicht geben.

Gruß, Ben

Benutzeravatar
Holgi
Elite
Elite
Beiträge: 2190
Registriert: 12.05.2018, 12:33
Hat sich bedankt: 225 Mal
Danke erhalten: 302 Mal
Gender:

Re: vbs script für download von MSRT (Malicious Software Removal Tool) - Anpassung & Hilfe nötig

Beitrag von Holgi » 30.12.2018, 18:26

Danke für den Tip mit dem wumgr.
LG
Holgi
PDF24 angepasste Installation (nur PDF Druckertreiber) per Script: viewtopic.php?t=30284
Winget (Desktop App Installer) für Windows Versionen ohne Store installieren (HowTo): viewtopic.php?t=26214
Vorstellung: tiny11builder; Script zur Verschlankung von Windows 11: viewtopic.php?t=30134
Windows StartMenü Empfohlen (Recommended Section) komplett ausblenden: viewtopic.php?t=30574
Hyper-V VM per Script erstellen viewtopic.php?t=25114

Benutzeravatar
Holgi
Elite
Elite
Beiträge: 2190
Registriert: 12.05.2018, 12:33
Hat sich bedankt: 225 Mal
Danke erhalten: 302 Mal
Gender:

Re: vbs script für download von MSRT (Malicious Software Removal Tool) - Anpassung & Hilfe nötig

Beitrag von Holgi » 15.12.2021, 11:20

mein geliebtes Script (modifiziert von Ben) zum Download der aktuellen MSRT Dateien (KB890830) funktioniert leider nicht mehr.
Es kommt die Fehlermeldung (z.B. ohne Versionsnummer)
Zeile 144
Zugriff verweigert
Code 80070005
Quelle: msxml3.dll

hat jemand eine Lösung?
PDF24 angepasste Installation (nur PDF Druckertreiber) per Script: viewtopic.php?t=30284
Winget (Desktop App Installer) für Windows Versionen ohne Store installieren (HowTo): viewtopic.php?t=26214
Vorstellung: tiny11builder; Script zur Verschlankung von Windows 11: viewtopic.php?t=30134
Windows StartMenü Empfohlen (Recommended Section) komplett ausblenden: viewtopic.php?t=30574
Hyper-V VM per Script erstellen viewtopic.php?t=25114

Blondi_2021
Poweruser
Poweruser
Beiträge: 740
Registriert: 08.04.2021, 12:37
Hat sich bedankt: 18 Mal
Danke erhalten: 106 Mal
Gender:

Re: vbs script für download von MSRT (Malicious Software Removal Tool) - Anpassung & Hilfe nötig

Beitrag von Blondi_2021 » 15.12.2021, 11:59


Benutzeravatar
Ben
★ Team Blog ★
Beiträge: 1004
Registriert: 28.12.2017, 15:19
Hat sich bedankt: 42 Mal
Danke erhalten: 73 Mal
Gender:

Re: vbs script für download von MSRT (Malicious Software Removal Tool) - Anpassung & Hilfe nötig

Beitrag von Ben » 15.12.2021, 12:36

Bei den beiden Zeilen im Script das "http://" in "https://" ändern dann sollte es hoffentlich wieder funktionieren.

Code: Alles auswählen

StrURL="http://download.microsoft.com/download/4/a/a/4aa524c6-239d-47ff-860b-5b397199cbf8/Windows-KB890830-V"

Code: Alles auswählen

StrURL64="http://download.microsoft.com/download/2/C/5/2C563B99-54D9-4D85-A82B-45D3CD2F53CE/Windows-KB890830-x64-V"
Sollten dann so aussehen die zwei Zeilen.

Code: Alles auswählen

StrURL="https://download.microsoft.com/download/4/a/a/4aa524c6-239d-47ff-860b-5b397199cbf8/Windows-KB890830-V"

Code: Alles auswählen

StrURL64="https://download.microsoft.com/download/2/C/5/2C563B99-54D9-4D85-A82B-45D3CD2F53CE/Windows-KB890830-x64-V"

Antworten