Batch to strip crap from Win10 Install.wim

Discussion in 'Scripting' started by Flipp3r, Aug 15, 2017.

  1. Flipp3r

    Flipp3r MDL Expert

    Feb 11, 2009
    1,473
    625
    60
    Hi guy's. A client has asked me for a stripped/clean version of Win10 Pro.
    My batch removes Home, onedrive, Disables Windows Consumer Features, & removes unwanted apps.
    Seems simple but:
    - Reg for Consumer Features does not exist on install.
    - Empty Tiles remain & app will download & install if tile clicked on.
    Can anyone see what I'm doing wrong. There seem to be many scripts using powershell while ONLINE which is not what I want. Any other suggestions? I do plan on Audit & sysprep...
    Code:
    @echo off
    
    Title --=== Windows 10 Pro 64bit Appz Removed ===--
    
    set PTH=%~dp0
    set wimlib=%PTH%..\wimlib\wimlib-imagex.exe
    
    ::********** Cleanup and Prep **********************************************************************************************************************
    Dism /Cleanup-Mountpoints
    Dism /Cleanup-Wim
    Del %PTH%*.wim /F /Q
    Del %PTH%*.esd /F /Q
    If Exist %PTH%Mount rd %PTH%Mount /S /Q
    md %PTH%Mount
    
    xcopy D:\SRC.Windows10.64.1703.483\sources\Install.wim
    
    :: ********** Delete Home **************************************************************************************************************************
    Dism /Delete-Image /ImageFile:%PTH%install.wim /Index:2
    
    ::********** PRO ***********************************************************************************************************************************
    Dism /Mount-Wim /WimFile:%PTH%install.wim /Index:1 /MountDir:%PTH%Mount
    
    ::---------- Remove Classic Executable, OneDrive Installer and Cloud Content -----------------------------------------------------------------------
    takeown /F %PTH%Mount\Windows\SysWOW64\OneDriveSetup.exe /A
    icacls %PTH%Mount\Windows\SysWOW64\OneDriveSetup.exe /grant "%username%":F
    del %PTH%Mount\Windows\SysWOW64\OneDriveSetup.exe
    reg load HKEY_LOCAL_MACHINE\WIM %PTH%Mount\Users\Default\ntuser.dat
    reg delete "HKEY_LOCAL_MACHINE\WIM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v OneDriveSetup /f
    reg add HKEY_LOCAL_MACHINE\WIM\SOFTWARE\Policies\Microsoft\Windows\CloudContent
    reg add HKEY_LOCAL_MACHINE\WIM\SOFTWARE\Policies\Microsoft\Windows\CloudContent /v "DisableWindowsConsumerFeatures" /t REG_DWORD /d "1" /f
    reg unload HKEY_LOCAL_MACHINE\WIM
    
    rem Dism /Image:%PTH%Mount /Get-ProvisionedAppxPackages >%PTH%AppList.txt
    Call AppList.cmd
    
    ::---------- PRO Without OA3 -----------------------------------------------------------------------------------------------------------------------
    Dism /Image:%PTH%Mount /Set-ProductKey:RHGJR-N7FVY-Q3B8F-KBQ6V-46YP4
    Dism /Capture-Image /CaptureDir:%PTH%Mount /ImageFile:%PTH%Pro_COA.wim /Name:"Win 10 Pro COA 1703 Removed Appz"
    IF %ERRORLEVEL% NEQ 0 pause
    
    Dism /Unmount-Wim /MountDir:%PTH%Mount /Discard
    
    
    
    "%wimlib%" export %PTH%Pro_COA.wim 1 %PTH%W10_1703_Build_15063.483_64_RemovedAppz.esd --solid
    
    :EOF
    Del %PTH%*.wim /F /Q
    rd %PTH%Mount /S /Q
    
    :EOF2
    Code:
    rem DISM /Image:%PTH%Mount /Remove-ProvisionedAppxPackage /PackageName:Microsoft.DesktopAppInstaller_1.1.25002.0_neutral_~_8wekyb3d8bbwe
    rem DISM /Image:%PTH%Mount /Remove-ProvisionedAppxPackage /PackageName:Microsoft.StorePurchaseApp_1.0.454.0_neutral_~_8wekyb3d8bbwe
    rem DISM /Image:%PTH%Mount /Remove-ProvisionedAppxPackage /PackageName:Microsoft.WindowsAlarms_2017.203.236.0_neutral_~_8wekyb3d8bbwe
    rem DISM /Image:%PTH%Mount /Remove-ProvisionedAppxPackage /PackageName:Microsoft.WindowsCalculator_2017.131.1904.0_neutral_~_8wekyb3d8bbwe
    DISM /Image:%PTH%Mount /Remove-ProvisionedAppxPackage /PackageName:Microsoft.3DBuilder_13.0.10349.0_neutral_~_8wekyb3d8bbwe
    DISM /Image:%PTH%Mount /Remove-ProvisionedAppxPackage /PackageName:Microsoft.BingWeather_4.18.56.0_neutral_~_8wekyb3d8bbwe
    DISM /Image:%PTH%Mount /Remove-ProvisionedAppxPackage /PackageName:Microsoft.Getstarted_4.5.6.0_neutral_~_8wekyb3d8bbwe
    DISM /Image:%PTH%Mount /Remove-ProvisionedAppxPackage /PackageName:Microsoft.Messaging_3.2.24002.0_neutral_~_8wekyb3d8bbwe
    DISM /Image:%PTH%Mount /Remove-ProvisionedAppxPackage /PackageName:Microsoft.Microsoft3DViewer_1.1702.21039.0_neutral_~_8wekyb3d8bbwe
    DISM /Image:%PTH%Mount /Remove-ProvisionedAppxPackage /PackageName:Microsoft.MicrosoftOfficeHub_2017.311.255.0_neutral_~_8wekyb3d8bbwe
    DISM /Image:%PTH%Mount /Remove-ProvisionedAppxPackage /PackageName:Microsoft.MicrosoftSolitaireCollection_3.14.1181.0_neutral_~_8wekyb3d8bbwe
    DISM /Image:%PTH%Mount /Remove-ProvisionedAppxPackage /PackageName:Microsoft.MicrosoftStickyNotes_1.4.101.0_neutral_~_8wekyb3d8bbwe
    DISM /Image:%PTH%Mount /Remove-ProvisionedAppxPackage /PackageName:Microsoft.MSPaint_1.1702.28017.0_neutral_~_8wekyb3d8bbwe
    DISM /Image:%PTH%Mount /Remove-ProvisionedAppxPackage /PackageName:Microsoft.Office.OneNote_2015.7668.58071.0_neutral_~_8wekyb3d8bbwe
    DISM /Image:%PTH%Mount /Remove-ProvisionedAppxPackage /PackageName:Microsoft.OneConnect_2.1701.277.0_neutral_~_8wekyb3d8bbwe
    DISM /Image:%PTH%Mount /Remove-ProvisionedAppxPackage /PackageName:Microsoft.People_2017.222.1920.0_neutral_~_8wekyb3d8bbwe
    DISM /Image:%PTH%Mount /Remove-ProvisionedAppxPackage /PackageName:Microsoft.SkypeApp_11.8.204.0_neutral_~_kzf8qxf38zg5c
    DISM /Image:%PTH%Mount /Remove-ProvisionedAppxPackage /PackageName:Microsoft.Wallet_1.0.16328.0_neutral_~_8wekyb3d8bbwe
    DISM /Image:%PTH%Mount /Remove-ProvisionedAppxPackage /PackageName:Microsoft.Windows.Photos_2016.511.9510.0_neutral_~_8wekyb3d8bbwe
    DISM /Image:%PTH%Mount /Remove-ProvisionedAppxPackage /PackageName:Microsoft.WindowsCamera_2017.125.40.0_neutral_~_8wekyb3d8bbwe
    DISM /Image:%PTH%Mount /Remove-ProvisionedAppxPackage /PackageName:microsoft.windowscommunicationsapps_2015.7906.42257.0_neutral_~_8wekyb3d8bbwe
    DISM /Image:%PTH%Mount /Remove-ProvisionedAppxPackage /PackageName:Microsoft.WindowsFeedbackHub_1.1612.10312.0_neutral_~_8wekyb3d8bbwe
    DISM /Image:%PTH%Mount /Remove-ProvisionedAppxPackage /PackageName:Microsoft.WindowsMaps_2017.209.105.0_neutral_~_8wekyb3d8bbwe
    DISM /Image:%PTH%Mount /Remove-ProvisionedAppxPackage /PackageName:Microsoft.WindowsSoundRecorder_2017.130.1208.0_neutral_~_8wekyb3d8bbwe
    DISM /Image:%PTH%Mount /Remove-ProvisionedAppxPackage /PackageName:Microsoft.XboxApp_2017.113.1250.0_neutral_~_8wekyb3d8bbwe
    DISM /Image:%PTH%Mount /Remove-ProvisionedAppxPackage /PackageName:Microsoft.XboxGameOverlay_1.15.2003.0_neutral_~_8wekyb3d8bbwe
    DISM /Image:%PTH%Mount /Remove-ProvisionedAppxPackage /PackageName:Microsoft.XboxIdentityProvider_2016.719.1035.0_neutral_~_8wekyb3d8bbwe
    DISM /Image:%PTH%Mount /Remove-ProvisionedAppxPackage /PackageName:Microsoft.XboxSpeechToTextOverlay_1.14.2002.0_neutral_~_8wekyb3d8bbwe
    DISM /Image:%PTH%Mount /Remove-ProvisionedAppxPackage /PackageName:Microsoft.ZuneMusic_2019.16112.11621.0_neutral_~_8wekyb3d8bbwe
    DISM /Image:%PTH%Mount /Remove-ProvisionedAppxPackage /PackageName:Microsoft.ZuneVideo_2019.16112.11601.0_neutral_~_8wekyb3d8bbwe
    DISM /Image:%PTH%Mount /Remove-ProvisionedAppxPackage /PackageName:Microsoft.WindowsStore_11701.1001.874.0_neutral_~_8wekyb3d8bbwe
     
  2. Tiger-1

    Tiger-1 MDL Guru

    Oct 18, 2014
    2,508
    2,551
    90
    ^^
    yep is insuperable tool when working with Windows 8.1 & Windows 10, sorry Flipper3 but I think that true is necessary speak
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. Flipp3r

    Flipp3r MDL Expert

    Feb 11, 2009
    1,473
    625
    60
  4. Tiger-1

    Tiger-1 MDL Guru

    Oct 18, 2014
    2,508
    2,551
    90
    @ Flipp3r ok, only remember MSMG Toolkit is free and have support for any doubts from here
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...