How can I uninstall Windows app packages through the command-line?

2

0

I know that Windows app (even the bloatware ones) can be removed through PowerShell, but I would like to achieve the same goal through the command-line processor. I used this guide that I found on How-To Geek to remove the apps I didn't want when I first used Windows, now I would like to make a batch script that automates the process. I already have my script set to delete all associated files and folders I want it to remove, but I can't figure out how to "translate" the PowerShell commands to do the same in cmd.

Here is the closest thing I have to completley removing an app with cmd / batch:

Get-AppxPackage *%APPNAME%* | Remove-AppxPackage
::This is the original PowerShell command that needs to be translated.

rmdir "%FOLDEREXAMPLE%" /s /q
del "%FILEEXAMPLE%" /s /q

Mr. Mendelli

Posted 2017-12-31T03:20:18.420

Reputation: 1 061

Why do you think this can be done in the command shell? And what would be the purpose of not using powershell to do this? Not everything can be done in a command prompt. That’s why Microsoft gave us powershell. – Appleoddity – 2017-12-31T03:32:44.913

For starters, I'm not very familiar with PowerShell so I like to work with what I'm more experienced with. If it can't be done with cmd then it can't, I'd just like to know how (if possible) this can be done. This is more of a learning experience than anything. I'll move on to PowerShell if need be. – Mr. Mendelli – 2017-12-31T03:37:22.110

Answers

3

To remove APPX packages, Remove-AppxPackage is the best and only one reliable command. Another way is to remove/delete the installed files of that app. Remember this procedure does not (and never will) truly uninstall that APPX package.

At first, find folders containing the APPX name (e.g. for "Weather" it will be "Microsoft.BingWeather") in the following directories:

C:\Program Files\WindowsApps\
C:\Users\<user_name>\AppData\Local\Packages\
C:\Windows\InfusedApps\Applications\
C:\Windows\InfusedApps\Packages\

Then make a batch file with the following commands and run it as administrator. Then enter the folders full path containing the appx name. Be cautious when you enter folder path, it should have the Appx name at last.

@echo off
set /p X=Enter Directory path: 
takeown /F %%X /R /D Y
icacls %%X /grant Everyone:F /T
rd /S /Q %%X
pause

Further reading:

Biswapriyo

Posted 2017-12-31T03:20:18.420

Reputation: 6 640