[SOLVED] Using dism with WUA

Questions about WAPT Packaging / Requests and help regarding Wapt packages.
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
Locked
Mikael S
Messages: 26
Registration: January 20, 2025 - 3:54 PM

February 18, 2026 - 4:23 PM

Good morning,

You may have encountered a problem repairing a Windows image with DISM in online mode using WUA. WAPT is blocking the operation. The tool likely needs to use WSU.

Here is a small package that allows you to bypass the problem, provided you prepare an image with the correct version.
This also includes a rapid audit to warn of system corruption.

Code: Select all

# -*- coding: utf-8 -*-
from setuphelpers import *

def install():
    if force:
        if not isdir(r'c:\tmp'):
            mkdirs(r'c:\tmp')

        winver = windows_version(4)

        with open(r"c:\tmp\install.wim", "wb") as file:
            with WAPT.waptserver.get_requests_session(use_ssl_auth=True) as session:
                with session.get("%s/%s" % (WAPT.waptserver.server_url, f"wapt/scripts/dism/{winver}.wim"),
                            timeout=WAPT.waptserver.timeout,
                            auth=None,
                            allow_redirects=True,
                            stream=True) as response:
                    if response.status_code == 404:
                        error(f'Version {winver} non gérée, merci de prendre contact avec le mainteneur')
                    for chunk in response.iter_content(chunk_size=8192):
                        file.write(chunk)

        print(run('DISM /Online /Cleanup-image /Scanhealth', timeout=900))
        print(run(r'DISM /Online /Cleanup-image /Restorehealth /Source:wim:c:\tmp\install.wim:1 /LimitAccess', timeout=900))
        print(run('sfc /scannow', timeout=900))

        remove_file(r'c:\tmp\install.win')

def audit():
    dism = run('DISM /Online /Cleanup-image /CheckHealth')

    print(dism)

    if "réparable" in dism:
        return "WARNING"
    else:
        return("OK")
And the procedure

Retrieve the original install.wim file from an ISO image

Mount the ISO under Windows and then copy the file X:\Sources\install.wim
Then export only the Windows Pro version using the command

Dism /Export-Image /SourceImageFile:"C:\install.wim" /SourceIndex:6 /DestinationImageFile:"C:\origin.wim"

It is also possible to retrieve the previously generated WIM file so that updates take less time
To do this, simply copy the old wim file to origin.wim


Generate a cumulative image

If necessary, create the c:\mount folder

Upload image

Mount-WindowsImage -Path C:\mount -ImagePath c:\origin.wim -Index 1

Download the cumulative report on https://www.catalog.update.microsoft.co ... -framework
Only one of the two packages is needed, the larger one

Add the cumulative to the image

Add-WindowsPackage -path c:\mount -PackagePath C:\windows11.0-kbxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxx.msu

Save image

Dismount-WindowsImage -Path C:\mount -Save

Export the image, specifying the Windows version number, for example 10.0.26100.7623

DISM.exe /Export-Image /SourceImageFile:c:\origin.wim /DestinationImageFile:c:\number_version_windows.wim /SourceIndex:1

The origin.wim file must be regenerated before it can be used again

Copy the resulting file to the Wapt server in /var/www/wapt/scripts/dism
Remember to assign the rights to www-data
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

February 18, 2026 - 5:53 PM

Mikael S wrote: Feb 18, 2026 - 4:23 PM WAPT is blocking the action. The tool probably needs to go through WSU.
No we do not pass not by wsus

However, we disable and re-enable the Windows Update service on demand. Perhaps the problem is simply that the Windows Update service is disabled

We use nothing more and nothing less than this: https://learn.microsoft.com/en-us/windo ... s=vbscript

Moreover, since Windows 11 24h2, installations are done using the dism command:

dism.exe /Online /Quiet /NoRestart /Add-Package /PackagePath:kb.msu
Mikael S
Messages: 26
Registration: January 20, 2025 - 3:54 PM

March 3, 2026 - 10:15

Yes, if I temporarily activate the service, it works. My mistake. It's simpler this way
User avatar
dcardon
WAPT Expert
Messages: 1929
Registration: June 18, 2014 - 09:58
Location: Saint Sébastien sur Loire
Contact :

March 16, 2026 - 10:11

Hi Mikaël,

thanks for the feedback :-) . I'm marking the topic as resolved.

Denis
Denis Cardon - Tranquil IT
Share your experiences on WAPT! Send us your blog and article URLs in the "Your Opinion of the forum, and we'll feature them on the WAPT
Locked