Windows 10 cleanup and upgrade

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
User avatar
Mathieu
Messages: 91
Registration: August 18, 2016 - 10:24

July 21, 2020 - 10:32

WAPT 1.8.2.7269
Server OS: Debian
OS DEV: Windows 10

Good morning,

I just updated my Windows10 upgrade package to v2004 and everything works perfectly.

I wanted to know if anyone had a solution via WAPT to clean up the residues from the update installation.

Because after installation I find myself with 16.3GB of space for temporary files "Previous Windows installations" which I would like to delete to free up space and put it in the audit section.

I found this which works, but not silently:

Code: Select all

New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Setup Files' -PropertyType 'DWORD' -Force -Name 'StateFlags1337' -Value 0x2
New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Previous Installations' -PropertyType 'DWORD' -Force -Name 'StateFlags1337' -Value 0x2
cleanmgr.exe /SAGERUN:1337
I also noticed that the windows10-upgrade package in the audit section was not working because it did not delete the "Windows Upgrade" folder.

By adding the variable upgrade_path = makepath(systemdrive,'WindowsUpgrade') in def audit and removing the try, the folder is deleted correctly.

Here is my modification:

Code: Select all

def audit():
    # Declaring specific app values
    package_version = control.version.split('-')[0]
    latest_version = package_version
    upgrade_path = makepath(systemdrive,'WindowsUpgrade')

    if Version(windows_version()) < Version(latest_version):
        print('Windows Upgrade has not succeed')
        return 'ERROR'
    elif isdir(upgrade_path):
        print('Windows %s already up-to-date' % windows_version())
        print('Cleanup as upgrade suceeded..')
        print('remove WindowsUpgrade')
        remove_tree(upgrade_path)
    else:
        print('Windows %s already up-to-date' % windows_version())
        return 'OK'
Thank you
- WAPT 2.2.3.12463 Enterprise
- Debian 9.9
- Windows 10 21H2 & Windows 11 22h2
User avatar
Mathieu
Messages: 91
Registration: August 18, 2016 - 10:24

August 14, 2020 - 08:48

Good morning,

Back from vacation, I'm getting back to the topic of cleaning up Windows 10 upgrades

I'm using the solution Simon gave me, but I'm having a problem: the Windows.old folder isn't being deleted, even though the permissions modification commands work whether I'm running as administrator or system

Do you have any leads?

Code: Select all

def install():
    package_version = control.version.split('-')[0]
    latest_version = package_version
    update_package_old = makepath(systemdrive,'Windows.old')

    if Version(windows_version()) < Version(latest_version):
        print('Windows Upgrade has not succeed')
        return 'ERROR'
    elif isdir(update_package_old):
        print('Windows %s already up-to-date' % windows_version())
        print('remove Windows_old')
        print('Changement proprietaire')
        run_powershell('takeown /F C:\Windows.old\* /R /A /D O')
        print('Modification droits')
        run_powershell('cacls c:\Windows.old\*.* /t /grant administrators:f')
        print('Supression Windows.old')
        run('rmdir /s /q c:\Windows.old')
        print('Cleanup as upgrade suceeded..')

    else:
        print('Windows %s already up-to-date' % windows_version())
        print('Cleanup as upgrade suceeded..')
        return 'OK'
- WAPT 2.2.3.12463 Enterprise
- Debian 9.9
- Windows 10 21H2 & Windows 11 22h2
User avatar
Mathieu
Messages: 91
Registration: August 18, 2016 - 10:24

August 14, 2020 - 11:39

The commands work manually if you check "Replace all permission entries for child objects," which I can't find in the command prompt
- WAPT 2.2.3.12463 Enterprise
- Debian 9.9
- Windows 10 21H2 & Windows 11 22h2
nliaudat
Messages: 29
Registration: August 8, 2019 - 8:31 AM

August 19, 2020 - 1:32 PM

To add inheritance:

Code: Select all

  iCACLS.exe /inheritance:e|d|r
          e - Enable inheritance
          d - Disable inheritance and copy the ACEs 
          r - Remove all inherited ACEs
Details below viewtopic.php?f=9&t=2439
nliaudat
Messages: 29
Registration: August 8, 2019 - 8:31 AM

August 26, 2020 - 11:09

Code: Select all

    run_notfatal('RD /S /Q "C:\$Windows.~BT"')
    run_notfatal('RD /S /Q "C:\$Windows.~WS"')
    run_notfatal('RD /S /Q "C:\$GetCurrent"')
    run_notfatal('RD /S /Q "C:\$WinREAgent"')
    run_notfatal('RD /S /Q "C:\update_win10.log"')
    run_notfatal('RD /S /Q "C:\Windows.old"')
    run_notfatal('RD /S /Q "C:\Windows10Upgrade"')
    run_notfatal('RD /S /Q "C:\WindowsUpgrade"')
Works perfectly for me, without changing the permissions.
User avatar
Mathieu
Messages: 91
Registration: August 18, 2016 - 10:24

August 29, 2020 - 12:28

I tried your commands.

I still have the Windows.old folder.

I can't find the right commands to properly clean it up after the upgrade.
- WAPT 2.2.3.12463 Enterprise
- Debian 9.9
- Windows 10 21H2 & Windows 11 22h2
jonathan.k
Messages: 16
Registration: March 13, 2020 - 3:24 PM

August 31, 2020 - 12:25

Hello,

just a thought, have you considered a PowerShell script?
nliaudat
Messages: 29
Registration: August 8, 2019 - 8:31 AM

September 1, 2020 - 11:12

This is simply a permissions issue. See the thread on iCACLS.exe: viewtopic.php?f=9&t=2439
nliaudat
Messages: 29
Registration: August 8, 2019 - 8:31 AM

September 1, 2020 - 11:27

Code: Select all

takeown /F "C:\Windows.old" /A /R /D Y
icacls "C:\Windows.old" /grant *S-1-5-32-544:F /T /C /Q
RD /S /Q "C:\Windows.old"
Locked