Skip to content

Instantly share code, notes, and snippets.

@hung1001
Last active May 23, 2017 01:48
Show Gist options
  • Save hung1001/6bad6f20b913b04f0e8c7c7263337cbe to your computer and use it in GitHub Desktop.
Save hung1001/6bad6f20b913b04f0e8c7c7263337cbe to your computer and use it in GitHub Desktop.
@echo off
color 0f
mode con cols=140 lines=30
Title Remove Provisioned Appx in Windows 10
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
if "%errorlevel%" NEQ "0" (
echo: Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo: UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs" & exit
)
if exist "%temp%\getadmin.vbs" del /f /q "%temp%\getadmin.vbs"
for /f "tokens=2*" %%c in ('"reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName" 2^>nul') do set ProductName=%%d
for /f "tokens=2*" %%a in ('"reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v CurrentBuild" 2^>nul') do set CurrentBuild=%%b
for /f "tokens=1-9" %%e in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "UBR" ^| find "REG_DWORD"') do set /a UBR=%%g
set packxbox=(XboxApp,XboxGameOverlay,XboxIdentityProvider,XboxSpeechToTextOverlay)
set packexceptstore=(3DBuilder,BingWeather,BingNews,DesktopAppInstaller,Getstarted,Messaging,Microsoft3DViewer,MicrosoftOfficeHub,MicrosoftSolitaireCollection,MicrosoftStickyNotes,MSPaint,Office.OneNote,OneConnect,People,SkypeApp,Wallet,Windows.Photos,WindowsAlarms,WindowsCalculator,WindowsCamera,windowscommunicationsapps,WindowsFeedbackHub,WindowsMaps,WindowsSoundRecorder,XboxApp,XboxGameOverlay,XboxIdentityProvider,XboxSpeechToTextOverlay,ZuneMusic,ZuneVideo)
set packincludestore=(3DBuilder,BingWeather,BingNews,DesktopAppInstaller,Getstarted,Messaging,Microsoft3DViewer,MicrosoftOfficeHub,MicrosoftSolitaireCollection,MicrosoftStickyNotes,MSPaint,Office.OneNote,OneConnect,People,SkypeApp,Wallet,Windows.Photos,WindowsAlarms,WindowsCalculator,WindowsCamera,windowscommunicationsapps,WindowsFeedbackHub,WindowsMaps,WindowsSoundRecorder,XboxApp,XboxGameOverlay,XboxIdentityProvider,XboxSpeechToTextOverlay,ZuneMusic,ZuneVideo,WindowsStore,StorePurchaseApp)
:main
cls
echo.&echo You are running: %ProductName%
echo Current Build: %CurrentBuild%.%UBR%&echo.
echo ---------------------------------------------------------------------------------------------------------------------------------------
echo Remove Provisioned Appx
echo ---------------------------------------------------------------------------------------------------------------------------------------
echo [1] : 3DBuilder [2] : BingWeather [3] : DesktopAppInstaller
echo [4] : Getstarted [5] : Messaging [6] : Microsoft3DViewer
echo [7] : MicrosoftOfficeHub [8] : SolitaireCollection [9] : StickyNotes
echo [10]: MSPaint 3D [11]: OneNote [12]: OneConnect
echo [13]: People [14]: SkypeApp [15]: StorePurchaseApp
echo [16]: Wallet [17]: Photos [18]: Alarms
echo [19]: Calculator [20]: Camera [21]: Communicationsapps
echo [22]: FeedbackHub [23]: Maps [24]: SoundRecorder
echo [25]: Store [26]: Xbox [27]: ZuneMusic
echo [28]: ZuneVideo [29]: News [30]: ALL Except Store
echo [31]: ALL
echo [X] : EXIT
echo ---------------------------------------------------------------------------------------------------------------------------------------
set /p select="Your choice is: "
if "%select%" EQU "1" (call:removepowershell "3DBuilder" & call:removeapp "3DBuilder")
if "%select%" EQU "2" (call:removepowershell "BingWeather" & call:removeapp "BingWeather")
if "%select%" EQU "3" (call:removepowershell "DesktopAppInstaller" & call:removeapp "DesktopAppInstaller")
if "%select%" EQU "4" (call:removepowershell "Getstarted" & call:removeapp "Getstarted")
if "%select%" EQU "5" (call:removepowershell "Messaging" & call:removeapp "Messaging")
if "%select%" EQU "6" (call:removepowershell "Microsoft3DViewer" & call:removeapp "Microsoft3DViewer")
if "%select%" EQU "7" (call:removepowershell "MicrosoftOfficeHub" & call:removeapp "MicrosoftOfficeHub")
if "%select%" EQU "8" (call:removepowershell "MicrosoftSolitaireCollection" & call:removeapp "MicrosoftSolitaireCollection")
if "%select%" EQU "9" (call:removepowershell "MicrosoftStickyNotes" & call:removeapp "MicrosoftStickyNotes")
if "%select%" EQU "10" (call:removepowershell "MSPaint" & call:removeapp "MSPaint")
if "%select%" EQU "11" (call:removepowershell "Office.OneNote" & call:removeapp "Office.OneNote")
if "%select%" EQU "12" (call:removepowershell "OneConnect" & call:removeapp "OneConnect")
if "%select%" EQU "13" (call:removepowershell "People" & call:removeapp "People")
if "%select%" EQU "14" (call:removepowershell "SkypeApp" & call:removeapp "SkypeApp")
if "%select%" EQU "15" (call:removepowershell "StorePurchaseApp" & call:removeapp "StorePurchaseApp")
if "%select%" EQU "16" (call:removepowershell "Wallet" & call:removeapp "Wallet")
if "%select%" EQU "17" (call:removepowershell "Windows.Photos" & call:removeapp "Windows.Photos")
if "%select%" EQU "18" (call:removepowershell "WindowsAlarms" & call:removeapp "WindowsAlarms")
if "%select%" EQU "19" (call:removepowershell "WindowsCalculator" & call:removeapp "WindowsCalculator")
if "%select%" EQU "20" (call:removepowershell "WindowsCamera" & call:removeapp "WindowsCamera")
if "%select%" EQU "21" (call:removepowershell "windowscommunicationsapps" & call:removeapp "windowscommunicationsapps")
if "%select%" EQU "22" (call:removepowershell "WindowsFeedbackHub" & call:removeapp "WindowsFeedbackHub")
if "%select%" EQU "23" (call:removepowershell "WindowsMaps" & call:removeapp "WindowsMaps")
if "%select%" EQU "24" (call:removepowershell "WindowsSoundRecorder" & call:removeapp "WindowsSoundRecorder")
if "%select%" EQU "25" (call:removepowershell "WindowsStore" & call:removeapp "WindowsStore")
if "%select%" EQU "26" (
for /d %%b in %packxbox% do (
call:removepowershell "%%b"
call:removeapp2 "%%b"
)
echo.&echo -----------------------------------------------------------------------------------
echo Press any key to back !
pause >nul
goto:main
)
if "%select%" EQU "27" (call:removepowershell "ZuneMusic" & call:removeapp "ZuneMusic")
if "%select%" EQU "28" (call:removepowershell "ZuneVideo" & call:removeapp "ZuneVideo")
if "%select%" EQU "29" (call:removepowershell "BingNews" & call:removeapp "BingNews")
if "%select%" EQU "30" (
for /d %%b in %packexceptstore% do (
call:removepowershell "%%b"
call:removeapp2 "%%b"
)
echo.&echo Press any key to back !
pause >nul
goto:main
)
if "%select%" EQU "31" (
for /d %%b in %packincludestore% do call:removepowershell "%%b"
for /f "tokens=2 delims=: " %%a in ('dism /online /Get-ProvisionedAppxPackages ^| find "PackageName"') do (
echo -----------------------------------------------------------------------------------
echo Removing %%a...
dism /online /Remove-ProvisionedAppxPackage /PackageName:%%a
)
echo.&echo -----------------------------------------------------------------------------------
echo Press any key to back !
pause >nul
goto:main
)
if "%select%" EQU "x" EXIT
if "%select%" EQU "X" EXIT
goto:eof
:removeapp
echo.&echo Removing %~1...
for /f "tokens=2 delims=: " %%b in ('dism /online /Get-ProvisionedAppxPackages ^| find /I "PackageName : Microsoft.%~1"') do (set PackageName=%%b)
if "%PackageName%" EQU "" (
echo.&echo Package doesn't exist...
) else (
dism /online /Remove-ProvisionedAppxPackage /PackageName:%PackageName%
)
echo.&echo -----------------------------------------------------------------------------------
echo Press any key to back !
pause >nul
goto:main
:removeapp2
echo -----------------------------------------------------------------------------------
echo Removing %~1...
for /f "tokens=2 delims=: " %%b in ('dism /online /Get-ProvisionedAppxPackages ^| find /I "PackageName : Microsoft.%~1"') do (set PackageName2=%%b)
if "%PackageName2%" EQU "" (
echo.&echo Package doesn't exist...
) else (
dism /online /Remove-ProvisionedAppxPackage /PackageName:%PackageName2%
)
goto:eof
:removepowershell
PowerShell.exe -Command "Get-AppxPackage *%~1* | Remove-AppxPackage"
goto:eof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment