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")
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
