Skip to content

Instantly share code, notes, and snippets.

@MichalStrehovsky
Last active September 10, 2015 23:17
Show Gist options
  • Save MichalStrehovsky/a1afb85267d3b252a5e4 to your computer and use it in GitHub Desktop.
Save MichalStrehovsky/a1afb85267d3b252a5e4 to your computer and use it in GitHub Desktop.
This script will strip all APPX packages from an offline Windows image (e.g. a WIM file extracted with DISM), or from the currently running instance of Windows.
@echo off
rem **************************************************************************************
rem * This script will strip all APPX packages from an offline Windows image (e.g. a WIM *
rem * file extracted with DISM.exe), or from the currently running instance of Windows. *
rem * Saves about 75% of the first logon time and won't clutter the system with stuff *
rem * you can get from the Store if you really need. *
rem **************************************************************************************
whoami /GROUPS | find "S-1-16-12288" >nul 2>&1 || (
echo You need to be an admin to run this.
pause
exit /b 1
)
set TARGET=/Online
if "%1" neq "" (
set TARGET=/Image:%1
)
set TMPFILE=%TMP%\appxcleaner-%RANDOM%
echo Getting list of provisioned packages...
echo.
rem Filter out Store. We really shouldn't remove Store...
dism %TARGET% /Get-ProvisionedAppxPackages | find "PackageName :" | find /V "Microsoft.WindowsStore" | find /V "Microsoft.Appconnector" > %TMPFILE%.1
> %TMPFILE%.2 (
for /f "tokens=*" %%a in (%TMPFILE%.1) do (
call :Strip %%a
)
)
echo Following packages will be removed:
echo -----------------------------------
type %TMPFILE%.2
echo.
choice /M Continue?
if ERRORLEVEL 2 (
exit /b 0
)
for /f "tokens=*" %%a in (%TMPFILE%.2) do (
echo Removing %%a
dism %TARGET% /Remove-ProvisionedAppxPackage /PackageName:%%a >nul
)
goto :EOF
:Strip
echo %3
exit /b 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment