Optimize-Offline Guide - Windows Debloating Tool, Windows 1803, 1903, 19H2, 1909, 20H1 and LTSC 2019

Discussion in 'Windows 10' started by KedarWolf, Jul 30, 2019.

  1. stan456

    stan456 MDL Novice

    Jul 29, 2015
    33
    0
    0
    Not when I try it. Says build 19402 is not a supported build
     
  2. drew84

    drew84 MDL Expert

    Mar 13, 2014
    1,396
    2,376
    60
    Covered Here,... script will work on Build 21301 (if you are prepared to do the work - not really that difficult)
     
  3. stan456

    stan456 MDL Novice

    Jul 29, 2015
    33
    0
    0
    works! thank you
     
  4. zbigniew59

    zbigniew59 MDL Senior Member

    May 14, 2016
    373
    171
    10
    Does the file - Set-Additional.ps1 - make a copy of the org settings?
    If so, where and how to restore these org settings?
    Now, to restore org settings, I have to reinstall the system - I don't know how to restore these org settings.
     
  5. mR0463

    mR0463 MDL Novice

    Feb 1, 2021
    5
    0
    0
    Code:
     # Before stopping and disabling any Scheduled Task, export their default values as a JSON file. This way we can revert any change back to default if required.
                Get-ScheduledTask | Select-Object -Property TaskName, Description, TaskPath, State | ForEach-Object -Process { [PSCustomObject] @{ TaskName = $PSItem.TaskName; Description = $PSItem.Description; TaskPath = $PSItem.TaskPath; State = $PSItem.State; SetState = 'Disabled' } } | ConvertTo-Json | Out-File -FilePath .\DefaultScheduledTasks.json
    Line 27 to 29 seems to exactly do that, if I am not mistaken. What I don't know is if there is a script to revert the saved default settings.

    EDIT: Lines 38 to 40 do the same for services.
     
  6. drew84

    drew84 MDL Expert

    Mar 13, 2014
    1,396
    2,376
    60
    #746 drew84, Feb 3, 2021
    Last edited: Feb 3, 2021
    If you Copy and Rename DefaultScheduledTasks.json to ScheduledTasks.json and replace the one in the setup folder
    Surely all you would then have to do is run Set-Additional.ps1 again (Online) to restore Defaults,... just a guess
     
  7. mR0463

    mR0463 MDL Novice

    Feb 1, 2021
    5
    0
    0
    That sounds pretty reasonable.
    Other question in that direction: Are these scripts (Set-Additional and Remove-OneDrive) supposed to be executed after system installation? I read the code and could not find any connection to the main scripts which are executed during optimization.
     
  8. drew84

    drew84 MDL Expert

    Mar 13, 2014
    1,396
    2,376
    60
    #748 drew84, Feb 3, 2021
    Last edited: Feb 3, 2021
    Indeed

    Applied via Configuration.json
    Code:
     "Additional": {
        "Setup": true,
    
    also... it goes without saying that
    ScheduledTasks.json, Services.json, Set-Additional.ps1 and SetupComplete.cmd
    all need to be examined and edited to suit your own personal requirements, prior to running the script.
     
  9. geepnozeex

    geepnozeex MDL Junior Member

    Oct 21, 2014
    81
    79
    0
  10. mR0463

    mR0463 MDL Novice

    Feb 1, 2021
    5
    0
    0
    #751 mR0463, Feb 15, 2021
    Last edited: Feb 15, 2021
    I encountered the same problem - does anybody have an idea? I can confirm that it has something to do with Set-Additional.ps1 - I have just restored my VM to an earlier state and it is working again. I'll try to find out myself where the problem is once I have some free time.

    EDIT: I just noticed that this has been partly answered before: It is WpnUserService in line 59 of Set-Additional.ps1 which you need to comment out.
    If you want to quickly reverse the change, you can enter the following into an elevated PowerShell prompt:

    Code:
    Get-ChildItem -Path "HKLM:\SYSTEM\CurrentControlSet\Services" | Where-Object -Property Name -Like *WpnUserService* | Set-ItemProperty -Name Start -Value 2 -Force -PassThru | Set-ItemProperty -Name UserServiceFlags -Value 3 -Force
    Afterwards, it was working normally again for me.
     
  11. SerpentDash

    SerpentDash MDL Novice

    Jul 17, 2019
    8
    7
    0
    Hi.
    Is there any way to implement onedrive Remove-OneDrive.ps1 and/or Set-Additional.ps1 to be executed in SetupComplete.cmd?
    Every time I want to to this, setup is 'corupted'. I know that commands in SetupComplete shouldn't give any output so I edited powershell scripts to not show / ask anything user but it's still not working. Redirecting output to nul not helps at all.
     
  12. zbigniew59

    zbigniew59 MDL Senior Member

    May 14, 2016
    373
    171
    10
    #753 zbigniew59, Feb 17, 2021
    Last edited: Feb 17, 2021
    You need to run this as administrator after installation.
    Path C: Windows / Setup / Scripts

    SetupComplete does this - you don't need to do anything in the scripts.

    Applied via Configuration.json

    "Additional": {
    "Setup": true,
    # 749 - read on
     
  13. SerpentDash

    SerpentDash MDL Novice

    Jul 17, 2019
    8
    7
    0
    Yeah I understand that...
    I'm just trying to execute those in SetupComplete.cmd
     
  14. drew84

    drew84 MDL Expert

    Mar 13, 2014
    1,396
    2,376
    60
    ...Think that was covered here
     
  15. yatopp

    yatopp MDL Novice

    Jul 17, 2011
    41
    12
    0
    I tried it like that, but I had issues to what SerpentDash is talking about - setup is 'corupted'. So left my SetupComplete.cmd without a call to Set-Additional.ps1 and there was no error in setup. I just executed it after installation.
     
  16. Stafamu

    Stafamu MDL Novice

    Sep 22, 2018
    33
    22
    0
    Remove this from Optimize-Offline.psm1
    Code:
            If ($InstallInfo.Architecture -ne 'amd64')
            {
                $PSCmdlet.WriteWarning($OptimizeData.UnsupportedImageArch -f $InstallInfo.Architecture)
                $TempDirectory | Purge
                Break
            }
     
  17. mR0463

    mR0463 MDL Novice

    Feb 1, 2021
    5
    0
    0
    I have installed the optimized image into a VM and booted into Audit mode to sysprep and capture it via FOG Server for deployment. I am trying to do as many things before sysprep as possible as to avoid having to do them on every system.
    It seems that something in Set-Additional.ps1 interferes with sysprep. Whenever I try to sysprep the installation after executing Set-Additional.ps1, a reboot into installation gets stuck before it gets to OOBE. Does anyone here happen to know which of the stopped services or tasks (or anything other) might cause this?
     
  18. drew84

    drew84 MDL Expert

    Mar 13, 2014
    1,396
    2,376
    60