tis-windows11-upgrade-template

0-113
Mise à niveau vers la dernière version de Windows 11 à partir de Windows 7, 8, 10 et 11 - Vous devez exécuter le "update-package" et le "build-package" pour chaque langue nécessaire avant de déployer le paquet
2022 téléchargements
Télécharger
Voir le résultat de la construction Voir l'analyse de VirusTotal
tis-windows11-upgrade-template icon
package           : tis-windows11-upgrade-template
version           : 0-113
architecture      : x64
section           : base
priority          : optional
name              : Windows 11 Upgrade Template
categories        : System and network
maintainer        : WAPT Team,Tranquil IT,Jimmy PELÉ,Pierre COSSON
description       : Upgrade to the latest version of Windows 11 from Windows 7, 8, 10 and 11 - You must execute the "update-package" and "build-package" for every single necessary language before deploying the package
depends           : 
conflicts         : tis-windows10-upgrade-data,tis-windows10-2004-upgrade,tis-windows10-20h2-upgrade
maturity          : PROD
locale            : all
target_os         : windows
min_wapt_version  : 2.2
sources           : https://www.microsoft.com/software-download/windows11
installed_size    : 31000000000
impacted_process  : SetupHost
description_fr    : Mise à niveau vers la dernière version de Windows 11 à partir de Windows 7, 8, 10 et 11 - Vous devez exécuter le "update-package" et le "build-package" pour chaque langue nécessaire avant de déployer le paquet
description_pl    : Aktualizacja do najnowszej wersji Windows 11 z Windows 7, 8, 10 i 11 - musisz wykonać "update-package" i "build-package" dla każdego niezbędnego języka przed wdrożeniem pakietu
description_de    : Upgrade auf die neueste Version von Windows 11 von Windows 7, 8, 10 und 11 - Sie müssen das "update-package" und "build-package" für jede einzelne benötigte Sprache ausführen, bevor Sie das Paket bereitstellen
description_es    : Actualizar a la última versión de Windows 11 desde Windows 7, 8, 10 y 11 - Debe ejecutar el "update-package" y "build-package" para cada uno de los idiomas necesarios antes de desplegar el paquete
description_pt    : Actualização para a última versão do Windows 11 a partir do Windows 7, 8, 10 e 11 - Deve executar o "update-package" e o "build-package" para cada uma das línguas necessárias antes de implementar o pacote
description_it    : Aggiornamento all'ultima versione di Windows 11 da Windows 7, 8, 10 e 11 - È necessario eseguire "update-package" e "build-package" per ogni singola lingua necessaria prima di distribuire il pacchetto
description_nl    : Upgrade naar de laatste versie van Windows 11 vanuit Windows 7, 8, 10 en 11 - U moet de "update-package" en "build-package" uitvoeren voor elke noodzakelijke taal voordat u het pakket implementeert
description_ru    : Обновление до последней версии Windows 11 с Windows 7, 8, 10 и 11 - необходимо выполнить команды "update-package" и "build-package" для каждого необходимого языка перед развертыванием пакета
audit_schedule    : 
editor            : Microsoft
keywords          : 
licence           : Proprietary
homepage          : https://www.microsoft.com/software-download/windows11
package_uuid      : 26301cfc-130b-4700-b056-72ee042d871d
valid_from        : 
valid_until       : 
forced_install_on : 
changelog         : https://docs.microsoft.com/windows/release-health/
min_os_version    : 6.1
max_os_version    : 
icon_sha256sum    : 9ccd55c246c5266669ff70a6e62c1e315666114c6d3f854071b6ff22fe48612b
signer            : Tranquil IT
signer_fingerprint: 8c5127a75392be9cc9afd0dbae1222a673072c308c14d88ab246e23832e8c6bb
signature         : xTN+ongO1buoBFA3dt7N14FqWplHDVBR+Uz5e05ZbdAizurac4L78aSKw8a0zjz6JcAZKgDbU/6TlB+ZMKYqaV20FHrmGf6MSG8C6vn5vW1neOWFiqbNv53+JFgF9lSp9WjQg5yUPXwhbbskUupp3B8ZtFz78SvViglbFLCOrrPgluNy4huh0krgCLHHx4P7evDk6BqmFwN6eiE4RlNhc2CcDYV8RD9z4ZrOKHfjPaDdaqB0z0eAOgXKJ/u6SgZifhtrm0q2g0An1+R5aGOHUmbSSxkkoJEK3l3fTzyCzgtSV444cEie2HuCsKWo2m6zxQZQsFCE4yVp0a9G1AY9PA==
signature_date    : 2023-03-17T18:00:11.156594
signed_attributes : package,version,architecture,section,priority,name,categories,maintainer,description,depends,conflicts,maturity,locale,target_os,min_wapt_version,sources,installed_size,impacted_process,description_fr,description_pl,description_de,description_es,description_pt,description_it,description_nl,description_ru,audit_schedule,editor,keywords,licence,homepage,package_uuid,valid_from,valid_until,forced_install_on,changelog,min_os_version,max_os_version,icon_sha256sum,signer,signer_fingerprint,signature_date,signed_attributes
# -*- coding: utf-8 -*-
from setuphelpers import *
import time


r"""
Sources:
https://docs.microsoft.com/windows-hardware/manufacture/desktop/windows-setup-command-line-options
https://www.prajwaldesai.com/windows-10-upgrade-setup-failed-with-exit-code-0xc1900200/
https://www.tomshardware.com/how-to/bypass-windows-11-tpm-requirement
https://docs.microsoft.com/windows-hardware/manufacture/desktop/windows-setup-command-line-options?view=windows-11#compat
https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/cleanmgr

Infos:
Forced install will automatically reboot the PC
This package can be updated graphically

"""
AllowUpgradesWithUnsupportedTPMOrCPU = False
DynamicUpdate = False
upgrade_path = makepath(systemdrive, "WindowsUpgrade")
upgrade_logs_path = makepath(systemdrive, "WindowsUpgradeLogs")
windows_old_path = makepath(systemdrive, "Windows.old")
cleanmgr_timeout = 660


def install():
    # Declaring local variables
    package_version = control.get_software_version()
    iso_path = makepath(basedir, "iso")
    cleanmgr_keys = [
        "Active Setup Temp Folders",
        "BranchCache",
        "Content Indexer Cleaner",
        "D3D Shader Cache",
        "Delivery Optimization Files",
        "Device Driver Packages",
        "Diagnostic Data Viewer database files",
        "Downloaded Program Files",
        "DownloadsFolder",
        "Internet Cache Files",
        "Language Pack",
        "Offline Pages Files",
        "Old ChkDsk Files",
        "Previous Installations",
        "Recycle Bin",
        "RetailDemo Offline Content",
        "Setup Log Files",
        "System error memory dump files",
        "System error minidump files",
        "Temporary Files",
        "Temporary Setup Files",
        "Temporary Sync Files",
        "Thumbnail Cache",
        "Update Cleanup",
        "Upgrade Discarded Files",
        "User file versions",
        "Windows Defender",
        "Windows Error Reporting Files",
        "Windows ESD installation files",
        "Windows Upgrade Log Files",
    ]

    # Checking if Windows must be upgraded
    if Version(windows_version(), 3) < Version(package_version, 3):
        # Trying to remove previous version of Windows if needed
        if isdir(windows_old_path) or isdir(r"C:\$Windows.~WS"):
            key_path = r"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches"
            key_value = r"StateFlags0042"
            for key in cleanmgr_keys:
                if "Upgrade Discarded Files" in key or "Previous Installations" in key:
                    registry_set(HKEY_LOCAL_MACHINE, makepath(key_path, key), key_value, 2)
                else:
                    registry_set(HKEY_LOCAL_MACHINE, makepath(key_path, key), key_value, 0)

            print("Removing previous version of Windows")
            cleanmgr_cmd = "cleanmgr /verylowdisk /sagerun:42"
            run_notfatal(cleanmgr_cmd, timeout=cleanmgr_timeout)  # seems to timeout on missing user graphical interface
            # run_powershell(r"Start-Process -FilePath CleanMgr.exe -ArgumentList '/sagerun:42 /verylowdisk' -WindowStyle Hidden -Wait")

            print("Waiting for custom CleanMgr")
            max_loop = cleanmgr_timeout
            while isrunning("cleanmgr"):
                loop = 0
                loop += 10
                if loop > max_loop:
                    print("CleanMgr timed out after %s seconds, trying to continue" % max_loop)
                    print('If the upgrade fail, please run: "%s" manually as asministrator on the PC' % cleanmgr_cmd)
                time.sleep(10)
                print("CleanMgr is running since %s seconds" % loop)
            print("CleanMgr finished")

        # Move iso
        if isdir(upgrade_path):
            remove_tree(upgrade_path)
        os.rename(iso_path, upgrade_path)

        if not isdir(upgrade_logs_path):
            mkdirs(upgrade_logs_path)

        # Upgrading Windows if needed
        if isdir(upgrade_path):
            print("%s folder exists, continuing..." % upgrade_path)
            print("Free disk space: %d bytes" % get_disk_free_space(upgrade_path))
            if get_disk_free_space(upgrade_path) < 25000000000:
                error("Not enough free space on disk for upgrade, please cleanup")
            else:
                # Changing cmd options
                additionnal_cmd = ""
                if AllowUpgradesWithUnsupportedTPMOrCPU:
                    registry_set(HKEY_LOCAL_MACHINE, r"SYSTEM\Setup\MoSetup", "AllowUpgradesWithUnsupportedTPMOrCPU", 1)
                    additionnal_cmd = additionnal_cmd + " /compat ignorewarning"
                if DynamicUpdate:
                    additionnal_cmd = additionnal_cmd + " /dynamicupdate enable"
                else:
                    additionnal_cmd = additionnal_cmd + " /dynamicupdate disable"

                if force:
                    try:
                        print("Force Upgrading Windows from version: %s to Windows version: %s" % (windows_version(), package_version))
                        run(
                            rf'"{makepath(upgrade_path, "setup.exe")}" /auto upgrade /quiet /eula accept /telemetry disable /showoobe none /copylogs "{makepath(upgrade_logs_path, "win11_upgrade_logs")}" {additionnal_cmd}',
                            timeout=5000,
                        )
                    except Exception as error_force_upgrade:
                        error(error_force_upgrade)
                else:
                    additionnal_cmd = additionnal_cmd + " /noreboot"
                    try:
                        print("Upgrading Windows from version: %s to Windows version: %s" % (windows_version(), package_version))
                        run(
                            rf'"{makepath(upgrade_path, "setup.exe")}" /auto upgrade /quiet /eula accept /telemetry disable /showoobe none /copylogs "{makepath(upgrade_logs_path, "win11_upgrade_logs")}" {additionnal_cmd}',
                            timeout=5000,
                        )
                    except Exception as error_upgrade:
                        error(error_upgrade)
        else:
            error("%s do not exist, please reinstall this package" % upgrade_path)
    else:
        print("This PC is already up-to-date on Windows version: %s" % windows_version())


def uninstall():
    if AllowUpgradesWithUnsupportedTPMOrCPU:
        registry_delete(HKEY_LOCAL_MACHINE, r"SYSTEM\Setup\MoSetup", "AllowUpgradesWithUnsupportedTPMOrCPU")
    if isdir(upgrade_path):
        print("Removing: %s" % upgrade_path)
        remove_tree(upgrade_path)
    if isdir(upgrade_logs_path):
        print("Removing: %s" % upgrade_logs_path)
        remove_tree(upgrade_logs_path)


def audit():
    if Version(windows_version()) < Version(control.get_software_version()):
        if isrunning("SetupHost"):
            print("WARNING: Windows upgrade is running...")
            return "WARNING"
        elif is_pending_reboot():
            print("WARNING: Please reboot this PC to finalize the upgrade")
            return "WARNING"
        else:
            print("ERROR: Windows upgrade failed")
            return "ERROR"
    else:
        print("OK: This PC is now up-to-date on Windows version: %s" % windows_version())
        print("Cleaning up since the upgrade was successful...")
        if isdir(upgrade_path):
            print("Removing: %s" % upgrade_path)
            remove_tree(upgrade_path)
        if isdir(upgrade_logs_path):
            print("Removing: %s" % upgrade_logs_path)
            remove_tree(upgrade_logs_path)
        return "OK"
# -*- coding: utf-8 -*-
from setuphelpers import *
import waptguihelper
import subprocess


def update_package():
    # Declaring local variables
    package_updated = False
    iso_path = makepath(basedir, "iso")
    setup_path = makepath(iso_path, "setup.exe")
    iso_present = False
    iso_extracted = False
    iso_copy_path = None
    iso_to_download = False
    keep_extracted_iso = False
    keep_current_iso = False

    lang_dict = {
        "fr": "French",
        "en": "English",
        "pl": "Polish",
        "de": "German",
        "es": "Spanish",
        "pt": "Portuguese",
        "it": "Italian",
        "nl": "Dutch",
        "ru": "Russian",
        "all": "Others",
    }
    lang_list = []
    for entry in lang_dict:
        lang_list.append({"short name": entry, "long name": lang_dict[entry]})

    # Detect ISO if placed
    for iso_in_dir in glob.glob("*.iso"):
        if isfile(iso_in_dir):
            iso_present = True

    # Detect ISO if already extracted
    if isfile(setup_path):
        iso_extracted = True

    if iso_present:
        keep_iso_present_question = waptguihelper.message_dialog("ISO found", f"Do you want to keep: {iso_in_dir}?", waptguihelper.ID_YES)
        if keep_iso_present_question == waptguihelper.ID_YES:
            keep_current_iso = True

    if iso_extracted:
        keep_iso_extracted_question = waptguihelper.message_dialog("An ISO is already extracted", "Do you want to keep it?", waptguihelper.ID_YES)
        if keep_iso_extracted_question == waptguihelper.ID_YES:
            keep_extracted_iso = True

    if keep_current_iso and keep_extracted_iso:
        keep_only_one_question = waptguihelper.grid_dialog(
            "Please select only one", [{"keep :": iso_in_dir}, {"keep :": "iso already extracted"}], waptguihelper.GRT_SELECTED
        )
        if "extracted" in keep_only_one_question[0]["keep :"]:
            keep_current_iso = False
        else:
            keep_extracted_iso = False

    if not keep_extracted_iso:
        if not iso_present:
            iso_absent_question = waptguihelper.message_dialog(
                "No ISO detected", "Do you want to download Windows ISO from Microsoft's servers?\nClick No to use your own ISO", waptguihelper.ID_YES
            )
            if iso_absent_question == waptguihelper.ID_YES:
                iso_to_download = True

    if iso_to_download:
        # Download from browser
        try:
            if isdir(makepath(programfiles32, "Google", "Chrome", "Application")):
                chrome_app_path = makepath(programfiles32, "Google", "Chrome", "Application")
            else:
                chrome_app_path = makepath(programfiles, "Google", "Chrome", "Application")
            chrome_bin_path = makepath(chrome_app_path, "chrome.exe")
            cmd_browser = rf'"{chrome_bin_path}" --user-agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko)Chrome/61.0.3163.100 Safari/537.36" --user-data-dir=%tmp%\chrome_tmp "{control.sources}"'
            waptguihelper.message_dialog(
                "Chrome will open with a custom user-agent",
                'Select "Download Windows 11 Disk Image (ISO)" => "Windows 11 (multi-edition ISO) => then your language. When the download is finished, please close the opened Chrome',
            )
            subprocess.Popen(cmd_browser, shell=True, start_new_session=True)
            waptguihelper.message_dialog("Waiting for download", "Click OK when the download is complete", waptguihelper.ID_OK)
        except:
            error(cmd_browser)

    # Copy to pkg
    if not keep_current_iso and not iso_present and not keep_extracted_iso:
        # Cleanup ISO files
        for iso_in_dir in glob.glob("*.iso"):
            remove_file(iso_in_dir)

        iso_copy_path = waptguihelper.filename_dialog("Please provide the Windows ISO to copy in this package", "", "", "ISO Files|*.iso")
        print("Copying: " + iso_copy_path)
        filecopyto(iso_copy_path, basedir)

    # Extracting ISO
    if not keep_extracted_iso:
        # Cleanup ISO dir
        if isdir(iso_path):
            remove_tree(iso_path)
        iso_in_dir = glob.glob("*.iso")[0]
        print("Extracting: " + iso_in_dir)
        unzip_with_7zip(iso_in_dir, iso_path)
        remove_file(iso_in_dir)

    # Getting version from the ISO setup.exe
    version = ".".join(get_file_properties(setup_path)["ProductVersion"].split(".")[:3])

    # Changing version of the package
    if Version(version) > control.get_software_version():
        print("Software version updated from: %s to: %s" % (control.get_software_version(), Version(version)))
        package_updated = True
    control.set_software_version(version)
    control.save_control_to_wapt()

    # Changing locale of the package
    lang_short = waptguihelper.grid_dialog("Please select a language", lang_list, waptguihelper.GRT_SELECTED)[0]["short name"]

    # Updating pkg infos
    if "-template" in control.package:
        package_name = waptguihelper.input_dialog(control.package, "You can redefine the package name", control.package.split("-template")[0])
        control.package = package_name
        if " Template" in control.name:
            control.name = control.name.split(" Template")[0]
        print("Changing package name to: %s" % package_name)
    control.locale = lang_short
    control.save_control_to_wapt()
    print("Changing locale to: %s in WAPT\\control" % control.locale)

    # Validating update-package-sources
    return package_updated
00387a0736a86592b8a2c1415e4038827e6f02043727f76d72603839b34ef090 : setup.py
7f19788294e5699166240ed238b8f160636530889257f7b5fa07b235fc298a92 : update_package.py
9ccd55c246c5266669ff70a6e62c1e315666114c6d3f854071b6ff22fe48612b : WAPT/icon.png
a5a97261381e1d0ad46ee15916abec9c2631d0201f5cc50ceb0197a165a0bbbf : WAPT/certificate.crt
f6118905197166eb5ced0ca5dc031aa75486e24188e25019b0bf967091e9d1bd : WAPT/changelog.txt
c38e1884806e902f5487d60d359cba52fa45c3f86900ed3e908054608d5286c2 : luti.json
e3e8960be78ab0ff998467a8712824f9b5c31c1cf65f5cdac74a7f7712644354 : WAPT/control
0-112
fix missing variables

0-110

Initial package based on tis-windows11-upgrade and tis-windows11-upgrade but reworked
Fix upload from Console by using version 0