SysPrep bereinigt nicht vollständig

Antwort erstellen


Diese Frage dient dazu, das automatisierte Versenden von Formularen durch Spam-Bots zu verhindern.
Smileys
:) ;) :smile: :lol: :hihi: :D :rofl: :muahah: :( :pff: :kopfstreichel: :ohno: :betruebt: :heulen: :kopfkratz: :duckundweg: :o :? :oops: :psst: :sauer: :-P :daumenrunter: :daumen: :dankeschoen: :thx: :dafür: :gähn:
Mehr Smileys anzeigen

BBCode ist eingeschaltet
[img] ist eingeschaltet
[flash] ist ausgeschaltet
[url] ist eingeschaltet
Smileys sind eingeschaltet

Die letzten Beiträge des Themas

Ich habe die Datenschutzerklärung gelesen und bin damit einverstanden.

   

Ansicht erweitern Die letzten Beiträge des Themas: SysPrep bereinigt nicht vollständig

Re: SysPrep bereinigt nicht vollständig

von DK2000 » 05.03.2022, 18:06

Habe da auch kein Abo. Würde mich aber auch mal interessieren, was da so steht.

Re: SysPrep bereinigt nicht vollständig

von Holgi » 05.03.2022, 12:40

@g-force:
Heise hat aktuell einen Artikel in Heise+
https://www.heise.de/ratgeber/Vorinstal ... ser.teaser

Leider kann ich da nicht tiefer reinschauen, weil ich kein Heise + abonniert habe bzw. für jeden Artikel zahle.

Re: SysPrep bereinigt nicht vollständig

von DK2000 » 26.02.2022, 12:49

Dein Vorhaben ist da nur schwer zu realisieren. Wüsste nicht, wie man das irgendwie sicher hinbekommt.

Das Problem ist ja, dass die "frische" Install.wim ein Windows (oder mehrere) Windows-Images enthält, welche noch nie gelaufen sind. Sobald Du eines dieser Images installierst und davon startest (egal ob Audit-Modus oder Normal), verändert sich das Image erheblich. Das wieder rückgängig zu machen, ohne die gewollten Änderungen, ist da nicht gerade einfach. Das schwierigste hier ist die Registry zurückzusetzen. Das habe ich schon bei Windows 7 aufgegeben. Und Sysprep ist dazu nicht in der Lage und auch nicht für so etwas gedacht.

Re: SysPrep bereinigt nicht vollständig

von g-force » 25.02.2022, 21:13

g-force hat geschrieben: 12.02.2022, 01:28 Neuester Effekt: Die Netzwerkkarte meldet nach dem Neustart "Netzwerkabel wurde entfernt". Es ist keine Verbindung im Netzwerk mehr möglich, selbst unter PXE nicht. Neustart, BIOS-Reset, CMOS - keine Änderung, die NIC wird erkannt, aber keine Verbindung. Nun noch das: Nach einem Tag stromlos geht der PC ohne Murren wieder ins Netzwerk...
Ich korrigiere meine Erkenntnisse: Nach einem (vernünftig gemachten) CMOS-Reset geht die NIC dann wieder. Da bleibt wohl was im NVRAM hängen.

Back2Topic: Eine "frische" WIM unterscheidet sich in einigen Details von einer WIM, die man nach SysPrep gecaptured hat. Was ich bisher festgestellt habe: Der Ordner "Users\Default" ist bereits mit Inhalt auf der frischen WIM enthalten, den Ordner "Users\Administrator" gibt es (noch) nicht. Wenn ich die "frische" WIM auf eine VHDX entrolle und mir mit "Windows Login Unlocker" die Accounts anschaue, dann ist da noch nichts enthalten. Bei einem Capture (nach SysPrep) sind die Standard-Accounts alle da. Ich vermute, daß die Registry-Zweige erst beim ersten Login (ALT-Shift-F3) angelegt werden und "Login Unlocker" dort ausliest.

Mein Bestreben ist es ja, eine möglichst "frische" WIM bzw. ISO mit Updates und Einstellungen zu erstellen, bei der dann NICHT Taskleiste oder andere Sachen zerschossen sind. Dies ist momentan nur durch eine Offline-Bearbeitung (NTlite, DISM++) möglich - mein alter Weg über Install & Capture funktioniert nur sehr unsauber. SysPrep setzt das System also bei weitem nicht in den "frischen" Zustand zurück.

Re: SysPrep bereinigt nicht vollständig

von g-force » 12.02.2022, 01:28

DK2000 hat geschrieben: 10.02.2022, 14:19 Aber das funktioniert auch nicht immer wie erwartet und kann auch passieren, dass dann Sachen in das Default-Profil kopiert werden, welche gar nicht für die Benutzer bestimmt sind. Da muss man aufpassen.
Folgendes Szenario: Ich richte (auf der Arbeit) einen PC mit bestimmten Einstellungen im SysPrep-Modus (also als Admin) ein. Ich führe meine CMD aus, die einige Dateien im Administrator-Konto löscht, dann "SysPrep-CopyProfile" ausführt. Das klappt(e) bisher gut, so wurde z.B. der Autostart und die Einstellungen von "OpenRGB" für Blinki-Blinki übernommen, auch Desktop-Bild und Ordneroptionen wurden übernommen. Fand ich klasse und habe mich gefreut...
Neuester Effekt: Die Netzwerkkarte meldet nach dem Neustart "Netzwerkabel wurde entfernt". Es ist keine Verbindung im Netzwerk mehr möglich, selbst unter PXE nicht. Neustart, BIOS-Reset, CMOS - keine Änderung, die NIC wird erkannt, aber keine Verbindung. Nun noch das: Nach einem Tag stromlos geht der PC ohne Murren wieder ins Netzwerk...

Re: SysPrep bereinigt nicht vollständig

von Holgi » 10.02.2022, 15:31

@DK2000 und @g-force : danke euch beiden. Werde ich mal ausprobieren.
@g-force:
Das Anwachsen der Installation und damit die Größe der resultierenden WIM ist das Problem
ist das Problem mittlerweile gelöst?
Am besten ist wohl, die Updates nicht online mit dem Admininstrator Account per Sysprep zu machen, sondern eine bereits "eingedampfte" (Stichwort Compress) install.wim zu nehmen.

Re: SysPrep bereinigt nicht vollständig

von DK2000 » 10.02.2022, 15:24

Ja, ich kenne das mit "CopyProfile" (hatte ich ja auch geschrieben), aber das ist nicht mehr unbedingt eine saubere Methode und führt nicht immer zum gewünschten Ergebnis.

Re: SysPrep bereinigt nicht vollständig

von g-force » 10.02.2022, 15:17

Holgi hat geschrieben: 10.02.2022, 13:46
Aber das ist auch wieder eine Wissenschaft für sich, ein neues sauberes Profil für den "Default-User" zu erstellen.
hat das hier jemand schon mal gemacht und kann Tips bzw. fertige Dateien liefern (zum selbst anpassen)?
Der Trick heißt "CopyProfile", den man zusamen mit Sysprep verwendet. Dabei wird das aktuelle Administrator-Profil in den DefaultUser kopiert und wird dann bei der nächsten Benutzereinrichtung als Vorlage genutzt.

Re: SysPrep bereinigt nicht vollständig

von g-force » 10.02.2022, 15:13

Möglichkeiten zur Bereinigung:
- im laufenden Windows "cleanmgr /verylowdisk" ausführen
- Im laufenden Windows, in gemounteter WIM oder VHDX: DISM++ Bereinigung
- offline mit NTlite
- angepasste "wimscript.ini" für "(G)ImageX" mit weiteren Exclusions

Re: SysPrep bereinigt nicht vollständig

von DK2000 » 10.02.2022, 14:19

Da gibt es in dem Sinne keine fertige Datei.

Es geht hier um den Ordner "C:\Users\Default". Das ist das Standard-Benutzer-Profil, welches für alle neu angelegten Benutzer verwendet wird. Änderungen müsste man hier vornehmen bzw. in der darin befindlichen NTUSER.DAT (HKCU Zweig der Registry).

Die andere Methode übe Sysprep basiert eigentlich nur darauf:

Code: Alles auswählen

<CopyProfile>true</CopyProfile>
Die Datei mit dem Inhalt kann man dann mit dem Schalter /unattend: übergeben. Dann wird im Großen und Ganzen das Profil " "C:\Users\Administartor" zu "C:\Users\Default". Aber das funktioniert auch nicht immer wie erwartet und kann auch passieren, dass dann Sachen in das Default-Profil kopiert werden, welche gar nicht für die Benutzer bestimmt sind. Da muss man aufpassen.

Re: SysPrep bereinigt nicht vollständig

von Holgi » 10.02.2022, 13:46

Aber das ist auch wieder eine Wissenschaft für sich, ein neues sauberes Profil für den "Default-User" zu erstellen.
hat das hier jemand schon mal gemacht und kann Tips bzw. fertige Dateien liefern (zum selbst anpassen)?

Re: SysPrep bereinigt nicht vollständig

von DK2000 » 10.02.2022, 13:09

SysPrep ist ja auch erst einmal kein Tool zur Bereinigung, sondern es ist ein Systemvorbereitung-Tool. Es findet zwar eine Bereinigung statt, aber nur im geringen Umfang. Was das Tool genau macht, kann man in den.xml nachschauen:

Code: Alles auswählen

C:\Windows\System32\Sysprep\ActionFiles
Bereinigung ist da immer so eine Sache. Prinzipiell reicht es, die normale Datenträger-Bereinigung auszuführen oder mittels einer Konfigurationsdatei für DISM bzw. ImageX Ordner oder Dateien vom /capture auszuschließen. Ohne Angabe wird eine Default-Liste verwendet, welche man aber erweitern kann:

Code: Alles auswählen

[ExclusionList]
\$ntfs.log
\hiberfil.sys
\pagefile.sys
\swapfile.sys
\System Volume Information
\RECYCLER
\Windows\CSC

[CompressionExclusionList]
*.mp3
*.zip
*.cab
\WINDOWS\inf\*.pnf
https://docs.microsoft.com/de-de/window ... windows-11

Ansonsten gibt es da nicht viel Möglichkeiten. Sobald man das Image im Audit-Mode startet, wird wird es bereits größer. Wenn man dann noch Online Updates hinzufügt, noch größer.



Wenn man jetzt in den Audit-Modus startet, befindet man sich im Profil "Administrator". Alle Änderungen auf Benutzerebene gehen natürlich verloren. wenn man das System wieder generalisiert. Wenn man möchte, dass diese Änderungen in das "Default-Profil" übertragen werden, muss man für SysPrep noch eine kleine Antwortdatei erstellen:

https://docs.microsoft.com/de-de/window ... windows-11
https://docs.microsoft.com/de-de/window ... windows-11

Aber das ist auch wieder eine Wissenschaft für sich, ein neues sauberes Profil für den "Default-User" zu erstellen.

Und der Schalter "/mode:vm" war mir so noch nicht bekannt. Habe ich auch noch nie verwendet. Schient aber speziell für Hyper-V VMs zu sein:

https://docs.microsoft.com/de-de/window ... -11#modevm

Re: SysPrep bereinigt nicht vollständig

von Holgi » 10.02.2022, 07:31

Ich habe die Sache mit Sysprep jetzt auch mal bei mir ausprobiert, um zu schauen, ob ich davon etwas für mich gebrauchen kann.

Ich hätte da mal ein paar Fragen:
1. die Bereinigung: machst du das händisch, oder läßt du da ein Script drüberfahren? Wenn ja, wie sieht das aus?

2. habe unter dem Administrator-Account alles upgedated (inkl. Store Apps) und einige sinnlose Sachen gelöscht.
Darunter u.a. diese Platzhalter Apps, die erst installiert werden, wenn man sie anklickt. Halt so, wie ich mir ein Windows vorstelle.
Ich war erstaunt, dass dann nach dem Sysprep Reboot mit OOBE und generalize bei dem dann neu erstellten Account alles wieder von vorne losgeht: die Platzhalter Apps (Spiele etc.) sind wieder da und viel schlimmer; die echten Apps im Store wollen auch alle wieder ein Update haben. Ledglich Windows ist Up-to-date. Ist das normal? Kann man das abstellen oder umgehen?
Der User (nach Sysprep mit OOBE) soll das Windows so vorfinden, wie ich es mir vorstelle.
Sonst ginge ja nur eine LTSC Version ohne Store, oder?

3. kannst du einen Unterschied feststellen zwischen
a) sysprep.exe /oobe /generalize /shutdown /mode:vm
und
b) sysprep.exe /oobe /generalize /shutdown
Soll ja einen zeitlichen Vorteil bringen; den kann ich nicht erkennen.

4. unter der Administrator Anmeldung kann ich keine erweiterte Sitzung einstellen. Dadurch ist die Display-Auflösung schlecht (was Eingaben erschwert) und ich kann nicht von dem Host per Drag&Drop kopieren.

Re: SysPrep bereinigt nicht vollständig

von g-force » 30.01.2022, 23:08

Das Problem sind eigentlich nicht die Updates, die bei mir ja online über WU abgerufen und installiert werden. Das Anwachsen der Installation und damit die Größe der resultierenden WIM ist das Problem - wie bereinige ich das möglichst effektiv?

Re: SysPrep bereinigt nicht vollständig

von Holgi » 30.01.2022, 19:15

das Script scheint unter Windows 11 nicht mehr zu funktionieren.
Aber ich habe bei meiner Recherche da etwas Neues von MS gefunden:

Code: Alles auswählen

Option Explicit



' Supported parameters:
'    /AppName: Name to pass to the WUA API as the 'calling application';
'             this appears in the Windows Update logs
'             Default: "WUA API Sample Script"
'    /Criteria: Search criteria to be used (see the WUA documentation for
'             IUpdateSearcher::BeginSearch for examples)
'             Default: Search for all non-installed, non-hidden software
'    /Automate: Don't prompt the user for various actions
'             Default: Prompt the user
'    /IgnoreSupersedence: Display all applicable updates, even those
'             superseded by newer updates
'             Default: Ignore supersedes updates
'    /Offline: Path to WSUSSCN2.cab file that should be used for offline sync
'             Default: Don't do offline sync
'    /Service: Update service that script should scan against
'             Available values: WU, MU, WSUS, DCAT, STORE, or an
'             identifying GUID of another service
'             Default: Default service (WSUS if machine is configured to
'                 use it, or MU if opted in, or WU otherwise)
'             Ignored if /Offline is set
'    /Hide: Hide updates found by the scan. Hidden updates will not
'             normally be installed by Automatic Updates.
'    /Show: Unhide any hidden updates found by the scan.
'    /NoDownload: Do not download any updates that the scan detects
'    /NoInstall: Do not install any updates that the scan detects
'    /ShowDetails: Show details about the updates found by the scan
'    /ShowBundle: Output information about the child updates in the 
'             bundled updates that are found
'    /RebootToComplete: Restart the computer if necessary to complete
'             installation

Function InstallationResultToText(result)
    Select Case result
        Case 2
            InstallationResultToText = "Succeeded"
        Case 3
            InstallationResultToText = "Succeeded with errors"
        Case 4
            InstallationResultToText = "Failed"
        Case 5
            InstallationResultToText = "Cancelled"
        Case Else
            InstallationResultToText = "Unexpected (" & result & ")"
    End Select
End Function

Function DeploymentActionToText(action)
    Select Case action
        Case 0
            DeploymentActionToText = "None (Inherit)"
        Case 1
            DeploymentActionToText = "Installation"
        Case 2
            DeploymentActionToText = "Uninstallation"
        Case 3
            DeploymentActionToText = "Detection"
        Case 4
            DeploymentActionToText = "Optional Installation"
        Case Else
            DeploymentActionToText = "Unexpected (" & action & ")"
    End Select
End Function


Function UpdateDescription(update)
    Dim description
    Dim I
    Dim category
    description = update.Title & " {" & update.Identity.UpdateID & "." & update.Identity.RevisionNumber & "}"
    If update.IsHidden Then
        description = description & " (hidden)"
    End If
    If WScript.Arguments.Named.Exists("ShowDetails") Then
        if update.KBArticleIDs.Count > 0 Then
            description = description & " ("
            For I = 0 To update.KBArticleIDs.Count -1
                If I > 0 Then
                    description = description & ","
                End If
                description = description & "KB" & update.KBArticleIDs.Item(I)
            Next
            description = description & ")"
        End If
        description = description & " Categories: "
        For I = 0 to update.Categories.Count - 1
            Set category = update.Categories.Item(I)
            If I > 0 Then
                description = description & ","
            End If
            description = description & category.Name & " {" & category.CategoryID & "}"
        Next
        description = description & " Deployment action: " & DeploymentActionToText(update.DeploymentAction)
    End If
    UpdateDescription = description
End Function

Dim appName
If WScript.Arguments.Named.Exists("AppName") Then
    appName = WScript.Arguments.Named.Item("AppName")
Else
    appName = "WUA API Sample Script"
End If

Dim criteria
If WScript.Arguments.Named.Exists("Criteria") Then
    criteria = WScript.Arguments.Named.Item("Criteria")
Else
    criteria = "IsInstalled=0 and Type='Software' and IsHidden=0"
End If

Dim isAutomated
isAutomated = WScript.Arguments.Named.Exists("Automate")

Dim ignoreSupersedence
ignoreSupersedence = WScript.Arguments.Named.Exists("IgnoreSupersedence")

Dim showBundle
showBundle = WScript.Arguments.Named.Exists("ShowBundle")

Dim serverSelection
Dim serviceId
serverSelection = 0
serviceId = ""

If WScript.Arguments.Named.Exists("Service") Then
    Select Case UCase(WScript.Arguments.Named.Item("Service"))
        Case "WU"
            serverSelection = 2
        Case "MU"
            serverSelection = 3
            serviceId = "7971f918-a847-4430-9279-4a52d1efe18d"
        Case "WSUS"
            serverSelection = 1
        case "DCAT"
            serverSelection = 3
            serviceId = "855E8A7C-ECB4-4CA3-B045-1DFA50104289"
        case "STORE"
            serverSelection = 3
            serviceId = "117cab2d-82b1-4b5a-a08c-4d62dbee7782"
        Case Else
            serverSelection = 3
            serviceId = WScript.Arguments.Named.Item("Service")
    End Select
End If

Dim noDownload
noDownload = WScript.Arguments.Named.Exists("NoDownload")

Dim noInstall
noInstall = WScript.Arguments.Named.Exists("NoInstall")

Dim hide
hide = WScript.Arguments.Named.Exists("Hide")

Dim show
show = WScript.Arguments.Named.Exists("Show")

Dim strInput
strInput = ""

Dim returnValue
returnValue = 0

Dim automaticUpdates
Dim updateSettings
Dim objWMIService
Dim colListOfServices
Dim objService

Dim secondInstallPass
secondInstallPass = false

Dim updateSession
Set updateSession = CreateObject("Microsoft.Update.Session")
updateSession.ClientApplicationID = appName

Dim updateServiceManager
Dim offlineService
If WScript.Arguments.Named.Exists("Offline") Then
    Set updateServiceManager = CreateObject("Microsoft.Update.ServiceManager")
    Set offlineService = updateServiceManager.AddScanPackageService(appName, WScript.Arguments.Named.Item("Offline"), 0)
    serverSelection = 3
    serviceId = offlineService.ServiceID
    WScript.Echo "Registered offline scan cab, service ID " & serviceId & vbCRLF
End If
    
Dim updateSearcher
Set updateSearcher = updateSession.CreateUpdateSearcher()
updateSearcher.ServerSelection = serverSelection
If serverSelection = 3 Then
    updateSearcher.ServiceId = serviceId
End If
If ignoreSupersedence Then
    updateSearcher.IncludePotentiallySupersededUpdates = true
End If



Dim searchResult
Set searchResult = updateSearcher.Search(criteria)


Dim I
Dim B
For I = 0 To searchResult.Updates.Count-1
    Set update = searchResult.Updates.Item(I)
    WScript.Echo I + 1 & "> " & UpdateDescription(update)
    If showBundle Then
        For B = 0 to update.BundledUpdates.Count-1
            WScript.Echo I+1 & "> " & B+1 & "> " & UpdateDescription(update.BundledUpdates.Item(B))
        Next
    End If
Next

Dim updatesToDownload
Set updatesToDownload = CreateObject("Microsoft.Update.UpdateColl")

If searchResult.Updates.Count = 0 Then
    WScript.Echo "There are no applicable updates."
Else
    WScript.Echo vbCRLF & "Checking search results:"

    Dim update
    Dim description
    Dim addThisUpdate
    Dim hideThisUpdate
    Dim showThisUpdate
    Dim atLeastOneAdded
    Dim propertyTest
    atLeastOneAdded = false
    Dim exclusiveAdded
    exclusiveAdded = false
    If noDownload And Not hide And Not show Then
        WScript.Echo "Skipping downloads as requested."
    Else
        For I = 0 to searchResult.Updates.Count-1
            Set update = searchResult.Updates.Item(I)
            description = UpdateDescription(update)
            addThisUpdate = false
            If hide And Not update.IsHidden Then
                strInput = "Y"
                If Not isAutomated Then
                    WScript.Echo I + 1 & "> : " & description  & _
                    " is now shown; do you want to hide it? ([Y]/N)"
                    strInput = WScript.StdIn.Readline
                    WScript.Echo
                End If
                If (strInput = "Y" or strInput = "y") Then
                    WScript.Echo "Hiding update"
                    update.IsHidden = true
                End If
            ElseIf show And update.IsHidden Then
                strInput = "Y"
                If Not isAutomated Then
                    WScript.Echo I + 1 & "> : " & description  & _
                    " is now hidden; do you want to show it? ([Y]/N)"
                    strInput = WScript.StdIn.Readline
                    WScript.Echo
                End If
                If (strInput = "Y" or strInput = "y") Then
                    WScript.Echo "Showing update"
                    update.IsHidden = false
                End If
            End If
                
            If exclusiveAdded Then
                WScript.Echo I + 1 & "> skipping: " & description & _
                    " because an exclusive update has already been selected"
            ElseIf Not noDownload Then
                propertyTest = false
                On Error Resume Next
                propertyTest = update.InstallationBehavior.CanRequestUserInput
                On Error GoTo 0
                If propertyTest = true Then
                    WScript.Echo I + 1 & "> skipping: " & description  & _
                    " because it requires user input"
                Else
                    propertyTest = true
                    On Error Resume Next
                    propertyTest = update.EulaAccepted
                    On Error GoTo 0
                    If propertyTest = false Then
                        If isAutomated Then
                            WScript.Echo I + 1 & "> skipping: " & description  & _
                            " because it has a license agreement that has not been accepted"
                        Else
                            WScript.Echo I + 1 & "> note: " & description  & _
                            " has a license agreement that must be accepted:"
                            WScript.Echo update.EulaText
                            WScript.Echo "Do you accept this license agreement? (Y/[N])"
                            strInput = WScript.StdIn.Readline
                            WScript.Echo 
                            If (strInput = "Y" or strInput = "y") Then
                                update.AcceptEula()
                                addThisUpdate = true
                            Else
                                WScript.Echo I + 1 & "> skipping: " & description  & _
                                " because the license agreement was declined"
                            End If
                        End If
                    Else
                        addThisUpdate = true
                    End If
                End If
                If addThisUpdate Then
                    propertyTest = 0
                    On Error Resume Next
                    propertyTest = update.InstallationBehavior.Impact
                    On Error GoTo 0
                    If propertyTest = 2 Then
                        If atLeastOneAdded Then
                            WScript.Echo I + 1 & "> skipping: " & description  & _
                            " because it is exclusive and other updates are being installed first"
                            addThisUpdate = false
                        End If
                    End If
                End If
                If addThisUpdate Then
                    If Not isAutomated Then
                        WScript.Echo I + 1 & "> : " & description  & _
                        " is applicable; do you want to install it? ([Y]/N)"
                        strInput = WScript.StdIn.Readline
                        WScript.Echo
                        If (strInput = "N" or strInput = "n") Then
                            WScript.Echo "Skipping update"
                            addThisUpdate = false
                       End If
                    End If
                End If
                If addThisUpdate Then
                    WScript.Echo I + 1 & "> adding: " & description  
                    updatesToDownload.Add(update)
                    atLeastOneAdded = true
                    On Error Resume Next
                    propertyTest = update.InstallationBehavior.Impact
                    On Error GoTo 0
                    If propertyTest = 2 Then
                        WScript.Echo "This update is exclusive; skipping remaining updates"
                        exclusiveAdded = true
                    End If
                End If
            End If
        Next
    End If
End If

Dim updatesToInstall
Set updatesToInstall = CreateObject("Microsoft.Update.UpdateColl")

Dim rebootMayBeRequired
rebootMayBeRequired = false

If (Not noDownload) And (updatesToDownload.Count > 0) Then
    WScript.Echo vbCRLF & "Downloading updates..."

    Dim downloader
    Set downloader = updateSession.CreateUpdateDownloader() 
    downloader.Updates = updatesToDownload
    downloader.Download()

    WScript.Echo vbCRLF & "Successfully downloaded updates:"

    For I = 0 To updatesToDownload.Count-1
        Set update = updatesToDownload.Item(I)
        If update.IsDownloaded = true Then
            WScript.Echo I + 1 & "> " & UpdateDescription(update) 
            updatesToInstall.Add(update) 
            propertyTest = 0
            On Error Resume Next
            propertyTest = update.InstallationBehavior.RebootBehavior
            On Error GoTo 0
            If propertyTest > 0 Then
                rebootMayBeRequired = true
            End If
        End If
    Next
End If

strInput = "N"
If noInstall Then
    WScript.Echo "Skipping install as requested."
Else
    If updatesToInstall.Count > 0 Then
        strInput = "Y"
        If rebootMayBeRequired = true Then
            WScript.Echo vbCRLF & "These updates may require a reboot."
        End If
        If Not isAutomated Then
            WScript.Echo  vbCRLF & "Would you like to install updates now? (Y/[N])"
            strInput = WScript.StdIn.Readline
            WScript.Echo 
        End If
    End If

    If (strInput = "Y" or strInput = "y") Then
        WScript.Echo "Installing updates..."
        Dim installer
        Set installer = updateSession.CreateUpdateInstaller()
        installer.Updates = updatesToInstall
        Dim installationResult
        Set installationResult = installer.Install()
 
        returnValue = 1
        'Output results of install
        WScript.Echo "Installation Result: " & _
        InstallationResultToText(installationResult.ResultCode) 
        WScript.Echo "Reboot Required: " & _ 
        installationResult.RebootRequired & vbCRLF 
        WScript.Echo "Listing of updates installed " & _
        "and individual installation results:" 
 
        For I = 0 to updatesToInstall.Count - 1
            WScript.Echo I + 1 & "> " & _
            UpdateDescription(updatesToInstall.Item(i)) & ": " & _
            InstallationResultToText(installationResult.GetUpdateResult(I).ResultCode) & _
            " HRESULT: " & installationResult.GetUpdateResult(I).HResult
            If installationResult.GetUpdateResult(I).HResult = -2145116147 Then
                WScript.Echo "An update needed additional downloaded content. Please rerun the script."
            End If
        Next
       
        If installationResult.RebootRequired And WScript.Arguments.Named.Exists("RebootToComplete") Then
            strInput = "Y"
            If Not isAutomated Then
                WScript.Echo  vbCRLF & "Would you like to reboot now to complete the installation? (Y/[N])"
                strInput = WScript.StdIn.Readline
                WScript.Echo 
            End If
            If (strInput = "Y" or strInput = "y") Then
                WScript.Echo "Committing installation..." & vbCRLF
                installer.Commit(0)
                WScript.Echo "Triggering restart in 30 seconds..." & vbCRLF
                Dim oShell
                Set oShell = WScript.CreateObject("WScript.Shell")
                oShell.Run "shutdown /r /t 30", 1
            End If     
        End If
    End If
End If

WScript.Quit (returnValue)
https://docs.microsoft.com/de-de/window ... ng-updates
Man kann es so aufrufen:

Code: Alles auswählen

cscript "WUA_SearchDownloadInstall.vbs" /automate
Leider kommen da noch sehr viele "Statusmeldungen", die ich gerne raus hätte.
Vlt. reicht es, alle Zeilen mit " WScript.Echo ..." zu löschen??!!

Nach oben