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. drew84

    drew84 MDL Expert

    Mar 13, 2014
    1,351
    2,307
    60
    you need to edit (to suit your own needs) their corresponding .json files in the same (setup) directory.. the options are then applied via SetupComplete.cmd during installation
    with the setting configuration.json "Setup": true,

    0x8007000e error would seem to point to a corrupt provider (data) store... google it for more info[/QUOTE]
     
  2. KedarWolf

    KedarWolf MDL Addicted

    Mar 17, 2016
    977
    870
    30
    [/QUOTE]

    I'm pretty sure you need to manually run Set-Additional.cmd after you install Windows. The Setup option I believe just runs the SetupComplete.cmd and only applies the below.

    Code:
    CD /D "%~dp0"
    
    REM Answer files should ALWAYS be removed from the 'Windows\Panther' and 'Windows\System32\Sysprep' directories immediately after they've been processed.
    
    PowerShell.exe -NoProfile -ExecutionPolicy Bypass -File "%WINDIR%\Setup\Scripts\Refresh-Explorer.ps1"
    DEL /F /Q "%WINDIR%\Setup\Scripts\Refresh-Explorer.ps1" >NUL 2>&1
    DEL /F /Q "%WINDIR%\Panther\unattend.xml" >NUL 2>&1
    DEL /F /Q "%WINDIR%\System32\Sysprep\unattend.xml" >NUL 2>&1
    DEL "%~f0"
    
     
  3. drew84

    drew84 MDL Expert

    Mar 13, 2014
    1,351
    2,307
    60
    Code:
    CD /D "%~dp0"
    
    REM Answer files should ALWAYS be removed from the 'Windows\Panther' and 'Windows\System32\Sysprep' directories immediately after they've been processed.
    
    PowerShell.exe -NoProfile -ExecutionPolicy Bypass -File "%WINDIR%\Setup\Scripts\Refresh-Explorer.ps1"
    DEL /F /Q "%WINDIR%\Setup\Scripts\Refresh-Explorer.ps1" >NUL 2>&1
    DEL /F /Q "%WINDIR%\Panther\unattend.xml" >NUL 2>&1
    DEL /F /Q "%WINDIR%\System32\Sysprep\unattend.xml" >NUL 2>&1
    DEL "%~f0"
    
    oops.. completely forgot that my SetupComplete.cmd was already edited to include (amongst other things)
    Code:
    call “%WinDir%\ Setup \ Scripts \ Set-Additional.cmd”
    
     
  4. rentay

    rentay MDL Junior Member

    Dec 30, 2013
    88
    17
    0
    #1264 rentay, Sep 1, 2021
    Last edited: Sep 1, 2021
    Seems error 0x8007000e refers to lack of memory or disk space

    Might try and run the script on a larger hdd and see if it still happens.

    Will try and run Set-Additional.cmd once Windows has finished installation.

    How can I amend the SetupComplete.cmd to include both ScheduledTasks & Services.json to be run when Setup: True is selected under configuration.json?
     
  5. spanishfly

    spanishfly MDL Senior Member

    Dec 5, 2018
    352
    527
    10
    I highly recommend *not* blindly running "Set-Additional.cmd"
    There are many posts on this thread from people who break their perfectly good OS after applying Set-Additional.cmd and can't understand why.
    There are many posts on the GitHub issues page where people have pointed out problems with that script and it just never gets fixed.

    The developer uses a "get-out-of-jail" pass by telling people that you have to understand what the script is doing and don't come weeping to him when stuff breaks.
    What this means is that the only way to use that script is to go through it line-by-line and research what it's doing.

    The optimize-offline project is very special. The Set-Additional.cmd is *not* at all special!!
    There is nothing that the Set-Additional.cmd script does that other Tasks/Services/Firewall tweaking scripts can't do. It's much easier to find a tweaking script written in command-line code rather than PowerShell. There are many good choices and they are much easier to edit to make them do what you want or reverse if something gets broken.
    That's my opinion....
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. rentay

    rentay MDL Junior Member

    Dec 30, 2013
    88
    17
    0
    Thanks
    Have just been going through the different options under Set-Additional.ps1 and maybe this is not something I want to run!
     
  7. spanishfly

    spanishfly MDL Senior Member

    Dec 5, 2018
    352
    527
    10
    #1267 spanishfly, Sep 1, 2021
    Last edited: Sep 1, 2021
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. rentay

    rentay MDL Junior Member

    Dec 30, 2013
    88
    17
    0
    Is there a way to amend the SetupComplete.cmd to include both ScheduledTasks & Services.json to be run when Setup: True is selected under configuration.json?
     
  9. drew84

    drew84 MDL Expert

    Mar 13, 2014
    1,351
    2,307
    60
    You could try something like this, save as Set Services Scheduled Tasks to Start DISABLED.cmd in setup directory
    Code:
    @rem *** Set Services Start = DISABLED ***
    sc stop DiagTrack
    sc stop diagnosticshub.standardcollector.service
    sc stop dmwappushservice
    sc stop RemoteRegistry
    sc stop TrkWks
    sc stop WMPNetworkSvc
    sc stop SysMain
    sc stop lmhosts
    sc stop VSS
    sc stop RemoteAccess
    sc stop WSearch
    sc stop iphlpsvc
    sc stop DoSvc
    sc stop ICEsoundService
    sc stop ClickToRunSvc
    sc stop SEMgrSvc
    sc stop RtkAudioUniversalService
    sc stop BDESVC
    sc stop TabletInputService
    sc stop SstpSvc
    sc stop NvTelemetryContainer
    sc stop HomeGroupListener
    sc stop HomeGroupProvider
    sc stop lfsvc
    sc stop MapsBroke
    sc stop NetTcpPortSharing
    sc stop SharedAccess
    sc stop WbioSrv
    sc stop WMPNetworkSvc
    
    sc config DiagTrack start= disabled
    sc config diagnosticshub.standardcollector.service start= disabled
    sc config dmwappushservice start= disabled
    sc config RemoteRegistry start= disabled
    sc config TrkWks start= disabled
    sc config WMPNetworkSvc start= disabled
    sc config SysMain start= disabled
    sc config lmhosts start= disabled
    sc config VSS start= disabled
    sc config RemoteAccess start= disabled
    sc config WSearch start= disabled
    sc config iphlpsvc start= disabled
    sc config DoSvc start= disabled
    sc config ICEsoundService start= disabled
    sc config ClickToRunSvc start= demand
    sc config SEMgrSvc start= disabled
    sc config RtkAudioUniversalService start= disabled
    sc config BDESVC start= disabled
    sc config TabletInputService start= disabled
    sc config SstpSvc start= disabled
    sc config NvTelemetryContainer start= disabled
    sc config HomeGroupListener start= disabled
    sc config HomeGroupProvider start= disabled
    sc config lfsvc start= disabled
    sc config MapsBroke start= disabled
    sc config NetTcpPortSharing start= disabled
    sc config SharedAccess start= disabled
    sc config WbioSrv start= disabled
    sc config WMPNetworkSvc start= disabled
    
    REM *** Set Scheduled Tasks = DISABLED ***
    schtasks /Change /TN "Microsoft\Windows\AppID\SmartScreenSpecific" /Disable
    schtasks /Change /TN "Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser" /Disable
    schtasks /Change /TN "Microsoft\Windows\Application Experience\ProgramDataUpdater" /Disable
    schtasks /Change /TN "Microsoft\Windows\Application Experience\StartupAppTask" /Disable
    schtasks /Change /TN "Microsoft\Windows\Autochk\Proxy" /Disable
    schtasks /Change /TN "Microsoft\Windows\Customer Experience Improvement Program\Consolidator" /Disable
    schtasks /Change /TN "Microsoft\Windows\Customer Experience Improvement Program\KernelCeipTask" /Disable
    schtasks /Change /TN "Microsoft\Windows\Customer Experience Improvement Program\UsbCeip" /Disable
    schtasks /Change /TN "Microsoft\Windows\Customer Experience Improvement Program\Uploader" /Disable
    schtasks /Change /TN "Microsoft\Windows\DiskDiagnostic\Microsoft-Windows-DiskDiagnosticDataCollector" /Disable
    schtasks /Change /TN "Microsoft\Windows\Maintenance\WinSAT" /Disable
    schtasks /Change /TN "Microsoft\Windows\Shell\FamilySafetyUpload" /Disable
    schtasks /Change /TN "Microsoft\Windows\SystemRestore\SR" /Disable
    schtasks /Change /TN "Microsoft\Office\OfficeTelemetryAgentLogOn" /Disable
    schtasks /Change /TN "Microsoft\Office\OfficeTelemetryAgentFallBack" /Disable
    schtasks /Change /TN "Microsoft\Office\Office 15 Subscription Heartbeat" /Disable
    schtasks /Change /TN "\Microsoft\Windows\Power Efficiency Diagnostics\AnalyzeSystem" /Disable
    
    REM schtasks /Change /TN "Microsoft\Windows\Autochk\Proxy" /Disable
    REM schtasks /Change /TN "Microsoft\Windows\CloudExperienceHost\CreateObjectTask" /Disable
    REM schtasks /Change /TN "Microsoft\Windows\DiskDiagnostic\Microsoft-Windows-DiskDiagnosticDataCollector" /Disable
    REM schtasks /Change /TN "Microsoft\Windows\DiskFootprint\Diagnostics" /Disable *** Not sure if should be disabled, maybe related to S.M.A.R.T.
    REM schtasks /Change /TN "Microsoft\Windows\FileHistory\File History (maintenance mode)" /Disable
    REM schtasks /Change /TN "Microsoft\Windows\Maintenance\WinSAT" /Disable
    REM schtasks /Change /TN "Microsoft\Windows\NetTrace\GatherNetworkInfo" /Disable
    REM schtasks /Change /TN "Microsoft\Windows\PI\Sqm-Tasks" /Disable
    REM schtasks /Change /TN "Microsoft\Windows\Time Synchronization\ForceSynchronizeTime" /Disable
    REM schtasks /Change /TN "Microsoft\Windows\Time Synchronization\SynchronizeTime" /Disable
    REM schtasks /Change /TN "Microsoft\Windows\Windows Error Reporting\QueueReporting" /Disable
    REM schtasks /Change /TN "Microsoft\Windows\WindowsUpdate\Automatic App Update" /Disable
    
    and call it by adding this line to setupcomplete.cmd (found in the same directory),
    Code:
    call “%WinDir%\ Setup \ Scripts \ Set Services Scheduled Tasks to Start DISABLED.cmd”
    
    ... obviously edit script to suit your own needs as pulled it off some notes I made some time ago. The format is merely what I am trying to convey.
     
  10. rentay

    rentay MDL Junior Member

    Dec 30, 2013
    88
    17
    0
    Thank you so much! Will give this a try tomorrow and will let you know
     
  11. spanishfly

    spanishfly MDL Senior Member

    Dec 5, 2018
    352
    527
    10
    @drew84 's way is great!
    Here is a way to handle services.
    Add "OOBE.cmd" to the "\Additional\Setup" folder along with SetupComplete.cmd
    OOBE.cmd is natively called by Windows Setup the same as SetupComplete.cmd
    As an aside, it's considered "best practice" to clear out your added scripts so for the one shared by @drew84 and my suggested OOBE.cmd you should add the following two lines of code to the *end* of SetupComplete.cmd
    Code:
    DEL /F /Q "%WINDIR%\Setup\Scripts\Start DISABLED.cmd" >NUL 2>&1
    DEL /F /Q "%WINDIR%\Setup\Scripts\OOBE.cmd" >NUL 2>&1
    OOBE.cmd
    Code:
    REM Disable unwanted services that run on a fresh install (plus NcaSvc that depends on iphlpsvc)
    for /d %%G in (
    WSearch,
    CDPSvc,
    DiagTrack,
    DsSvc,
    DusmSvc,
    iphlpsvc,
    NcaSvc,
    SgrmBroker,
    SmsRouter,
    SSDPSRV,
    SysMain,
    TabletInputService
    ) do (
    sc config %%G start= disabled
    )

    The same @drew84 note applies "... obviously edit script to suit your own needs ... The format is merely what I am trying to convey."
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  12. rentay

    rentay MDL Junior Member

    Dec 30, 2013
    88
    17
    0
    So just trying to understand how the setup:true works (under configuration.json)

    This runs setup.cmd once Windows has finished installing. Without any editing to the setup.cmd, this will only run refresh-explorer and unattended xml?

    If I didn’t make any adjustments to the original setup.cmd and did not have an unattended file then changing setup:false in the configuration would be ok?

    I think in gdeliana’s fork it is set as true?
     
  13. drew84

    drew84 MDL Expert

    Mar 13, 2014
    1,351
    2,307
    60
    #1273 drew84, Sep 1, 2021
    Last edited: Sep 1, 2021
    there is an explanation file contained within the folder... any .cmd file will be executed during installation...
    for example: if you don't want to run Set-Additional.ps1 then delete Set-Additional.cmd

    by the same method.. if you find powershell scripts online that you want to run, just place them in the same folder... and
    create a .cmd file to call(run) them... using the Set-Additional.cmd as a template ... for example - found .ps1 script (Tell Windows to **** off.ps1)
    .cmd file would be called Tell Windows to **** off.cmd... and would look like this:
    Code:
    @ECHO OFF
    CD /D "%~dp0"
    
    NET SESSION >NUL 2>&1
    IF %ERRORLEVEL% NEQ 0 (
        ECHO Permission denied. This script must be run as an Administrator.
        ECHO:
        PAUSE
        EXIT
    ) ELSE (
        PowerShell.exe -NoProfile -ExecutionPolicy Bypass -File .\Set-Tell Windows to **** off.ps1 -Argument 2> .\Set-Tell Windows to **** off.error
        DEL /F /Q "%~dp0Set-Tell Windows to **** off.error" >NUL 2>&1
        DEL /F /Q "%~dp0Set-Tell Windows to **** off.ps1" >NUL 2>&1
        DEL /F /Q "%~f0" >NUL 2>&1
    )
    PAUSE
    EXIT
    
    ... pretty sure this is correct, but if I am wrong... you get the gist
     
  14. drew84

    drew84 MDL Expert

    Mar 13, 2014
    1,351
    2,307
    60
    ... forgot to mentiom THE most important point.... @gdeliana's fork is designed to push the boundries of what is currently available with original script...
    so using it... assumes you actually know (or at least have an idea of) what you are doing (in otherwords .. if something goes wrong it is your (your-your-your... etc) fault/problem
     
  15. spanishfly

    spanishfly MDL Senior Member

    Dec 5, 2018
    352
    527
    10
    #1275 spanishfly, Sep 1, 2021
    Last edited: Sep 1, 2021
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  16. drew84

    drew84 MDL Expert

    Mar 13, 2014
    1,351
    2,307
    60
  17. spanishfly

    spanishfly MDL Senior Member

    Dec 5, 2018
    352
    527
    10
    #1277 spanishfly, Sep 1, 2021
    Last edited: Sep 1, 2021
    Wow! thanks for sharing that.
    I should have said "drew84's proposed solution" or at least that was what I meant when I called it "your method".
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  18. rentay

    rentay MDL Junior Member

    Dec 30, 2013
    88
    17
    0
    Just did a run of OO (gdeliana's fork) and everything went well with no errors.

    The issue I had previously (error code 0x8007000e) has not returned as I loaded OO on a different ssd with more free space.

    I am using this to slim down LTSC 1809 (updated with W10UI to latest updates). Are there any other Services/Features etc I should disable/remove? Have included the log below

    Code:
    ***************************************************************************************************
    Running Module : Optimize-Offline 4.0.1.7
    Optimize Start : 09/02/2021 03:46:56 PM
    Identity Name  : SirSSV
    Computer Name  : LAPTOP
    ***************************************************************************************************
    
    2021-09-02T15:46:56 [INFO]: Supported Image Build: [17763]
    2021-09-02T15:46:59 [INFO]: Mounting Windows 10 Enterprise LTSC
    2021-09-02T15:49:21 [INFO]: Pre-Optimization Image Health State: [Healthy]
    2021-09-02T16:03:27 [INFO]: Removing System App: InputApp
    2021-09-02T16:03:29 [INFO]: Removing System App: Microsoft.AAD.BrokerPlugin
    2021-09-02T16:03:31 [INFO]: Removing System App: Microsoft.BioEnrollment
    2021-09-02T16:03:33 [INFO]: Removing System App: Microsoft.ECApp
    2021-09-02T16:03:35 [INFO]: Removing System App: Microsoft.LockApp
    2021-09-02T16:03:37 [INFO]: Removing System App: Microsoft.MicrosoftEdgeDevToolsClient
    2021-09-02T16:03:40 [INFO]: Removing System App: Microsoft.Win32WebViewHost
    2021-09-02T16:03:42 [INFO]: Removing System App: Microsoft.Windows.AddSuggestedFoldersToLibarayDialog
    2021-09-02T16:03:44 [INFO]: Removing System App: Microsoft.Windows.Cortana
    2021-09-02T16:03:46 [INFO]: Removing System App: Microsoft.Windows.FileExplorer
    2021-09-02T16:03:48 [INFO]: Removing System App: Microsoft.Windows.FilePicker
    2021-09-02T16:03:50 [INFO]: Removing System App: Microsoft.Windows.ParentalControls
    2021-09-02T16:03:52 [INFO]: Removing System App: Microsoft.Windows.PeopleExperienceHost
    2021-09-02T16:03:54 [INFO]: Removing System App: Microsoft.Windows.SecHealthUI
    2021-09-02T16:03:56 [INFO]: Removing System App: Microsoft.XboxGameCallableUI
    2021-09-02T16:03:58 [INFO]: Removing System App: Windows.CBSPreview
    2021-09-02T16:04:01 [INFO]: Disabling Services, Drivers and Integration Content for Removed Apps.
    2021-09-02T16:04:08 [INFO]: Removing Windows Biometric Capability Packages.
    2021-09-02T16:04:29 [INFO]: Disabling Optional Feature: Windows-Defender-Default-Definitions
    2021-09-02T16:04:35 [INFO]: Importing Custom App Associations.
    2021-09-02T16:07:24 [INFO]: Removing Windows Capability: App.Support.QuickAssist
    2021-09-02T16:07:29 [INFO]: Removing Windows Capability: Language.Handwriting
    2021-09-02T16:07:34 [INFO]: Removing Windows Capability: Language.OCR
    2021-09-02T16:07:39 [INFO]: Removing Windows Capability: Language.Speech
    2021-09-02T16:07:45 [INFO]: Removing Windows Capability: MathRecognizer
    2021-09-02T16:07:50 [INFO]: Removing Windows Capability: OneCoreUAP.OneSync
    2021-09-02T16:07:57 [INFO]: Removing Windows Capability: OpenSSH.Client
    2021-09-02T16:09:07 [INFO]: Disabling Optional Feature: MicrosoftWindowsPowerShellV2Root
    2021-09-02T16:11:04 [INFO]: Disabling Optional Feature: FaxServicesClientPackage
    2021-09-02T16:11:10 [INFO]: Disabling Optional Feature: MSRDC-Infrastructure
    2021-09-02T16:11:15 [INFO]: Disabling Optional Feature: Printing-XPSServices-Features
    2021-09-02T16:11:20 [INFO]: Disabling Optional Feature: SmbDirect
    2021-09-02T16:11:26 [INFO]: Disabling Optional Feature: WorkFolders-Client
    2021-09-02T16:11:50 [INFO]: Enabling Optional Feature: DirectPlay
    2021-09-02T16:11:56 [INFO]: Enabling Optional Feature: LegacyComponents
    2021-09-02T16:12:01 [INFO]: Applying Optimized Registry Settings.
    2021-09-02T16:12:13 [INFO]: Applying Setup Content.
    2021-09-02T16:12:17 [INFO]: Importing Registry Template: Additional Tweaks.reg
    2021-09-02T16:12:23 [INFO]: Cannot perform a clean-up of the Component Store while there are pending installations.
    2021-09-02T16:12:23 [INFO]: Cleaning-up the Start Menu Layout.
    2021-09-02T16:12:27 [INFO]: Disabling Windows Update
    2021-09-02T16:12:28 [INFO]: Disabling automatic driver update
    2021-09-02T16:12:29 [INFO]: Enabling dormant OneDrive fix
    2021-09-02T16:12:35 [INFO]: Post-Optimization Image Health State: [Healthy]
    2021-09-02T16:12:39 [INFO]: Saving and Dismounting Windows 10 Enterprise LTSC
    2021-09-02T16:15:28 [INFO]: Rebuilding and Exporting Windows 10 Enterprise LTSC using Maximum compression.
    2021-09-02T16:16:01 [INFO]: Optimizing the Installation Media File Structure.
    2021-09-02T16:16:01 [INFO]: Creating a No-Prompt Bootable Windows Installation Media ISO.
    2021-09-02T16:16:09 [INFO]: Finalizing Optimizations.
    2021-09-02T16:16:09 [INFO]: Optimize-Offline completed in [29] minutes with [0] errors.
    
    ***************************************************************************************************
    Optimizations Finalized : 09/02/2021 04:16:09 PM
    ***************************************************************************************************
    
    Not sure why there OO cannot perform a clean-up of the component store. Could it be because LTSC does not include Windows Store?
     
  19. No nothing extra is needed for stability purpose of M$ OS n let M$ continuesly collect resources.
     
  20. spanishfly

    spanishfly MDL Senior Member

    Dec 5, 2018
    352
    527
    10
    (AFAIK) If you want to search for apps in the native start menu, then you want to keep the System App of Microsoft.Windows.Cortana
    Cortana system app is not the same as the Windows store app. All it does is search. If you keep it, it shows in the "App history" in task manager but it it's using 0 resources. "Cortana" as search only uses resources when you search for built-in or installed apps in the start menu. When you're done searching, Cortana (search) surrenders the memory back to the system. (AFAIK)

    It's been a long time since I optimized build 17763 so I don't think there is anything else you can remove.
    These are all safe to remove, but I think they start to show up in builds later than LTSC 1809:
    Microsoft.Windows.AppRep.ChxApp
    Microsoft.Windows.AppResolverUX
    Microsoft.Windows.AssignedAccessLockApp
    Microsoft.Windows.CapturePicker
    Microsoft.Windows.ContentDeliveryManager
    Microsoft.Windows.PinningConfirmationDialog
    Microsoft.Windows.SecureAssessmentBrowser
    Microsoft.Windows.XGpuEjectDialog

    What are you using?. A Celeron with a 2005 era 40GB hard disk?:cool:
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...