Uninstalling ALL store apps with a script

Page 1 of 2 12 LastLast

  1. Posts : 102
    Windows 10 Pro
       #1

    Uninstalling ALL store apps with a script


    I know absolutely nothing about Powershell, and I don't even want to.
    I would like to uninstall ALL store apps through a script/batch file or something. Could anyone tell me how?
    Apparently this is the Ps command to use "Get-AppxPackage -allusers | Remove-AppxPackage" - but I have no idea how to integrate this into a batch file.
      My Computer


  2. Posts : 42,979
    Win 10 Pro (22H2) (2nd PC is 22H2)
       #2

    Then you won't want to read this:
    Running PowerShell Scripts Is as Easy as 1-2-3 | IT Pro
    as to run a PS script you have to set an execution policy.
    Change PowerShell Script Execution Policy in Windows 10 | Windows 10 Tutorials

    A PowerShell script is simply a text file with a .ps1 extension that contains a list of commands PowerShell should execute. However, PowerShell's secure by default philosophy prevents all scripts from running, so double-clicking a PowerShell script from Windows Explorer won't execute it.

    windows - How to run a PowerShell script? - Stack Overflow.
      My Computers


  3. Posts : 102
    Windows 10 Pro
    Thread Starter
       #3

    Thanks.
    Which execution policy do I need to use though?
    And how do I change it back when it's done? (if it works)
      My Computer


  4. Posts : 2,450
    Windows 10 Pro x64
       #4

    Octopuss said:
    Thanks.
    Which execution policy do I need to use though?
    And how do I change it back when it's done? (if it works)
    Code:
    Set-ExecutionPolicy Bypass -Scope Process
    It will bypass the executionpolicy currently in place, for the session only.
    i.e Run your script and when you exit PowerShell everything is as before.
      My Computer


  5. Posts : 5,452
    Windows 11 Home
       #5

    Octopuss said:
    but I have no idea how to integrate this into a batch file.
    Code:
    %WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe "Get-AppxPackage -AllUsers | Remove-AppxPackage"
      My Computer


  6. Posts : 102
    Windows 10 Pro
    Thread Starter
       #6

    Hm, doesn't work.
    The script literally only does this:
    Set-ExecutionPolicy Bypass -Scope Process
    Get-AppxPackage -allusers | Remove-AppxPackage

    The command I run from a batch file is
    Code:
    powershell "%SystemDrive%\install\remove-store-apps.ps1"
    I still get the "usual" error message.
    Code:
    c:\Install>powershell "%SystemDrive%\install\remove-store-apps.ps1"
    C:\install\remove-store-apps.ps1 : File C:\install\remove-store-apps.ps1 cannot be loaded because running scripts is di
    sabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135
    170.
    At line:1 char:1
    + C:\install\remove-store-apps.ps1
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : SecurityError: (:) [], PSSecurityException
        + FullyQualifiedErrorId : UnauthorizedAccess
    
    c:\Install>
      My Computer


  7. Posts : 2,450
    Windows 10 Pro x64
       #7

    Octopuss said:
    Hm, doesn't work.
    The script literally only does this:
    Set-ExecutionPolicy Bypass -Scope Process
    Get-AppxPackage -allusers | Remove-AppxPackage

    The command I run from a batch file is
    Code:
    powershell "%SystemDrive%\install\remove-store-apps.ps1"
    I still get the "usual" error message.
    Code:
    c:\Install>powershell "%SystemDrive%\install\remove-store-apps.ps1"
    C:\install\remove-store-apps.ps1 : File C:\install\remove-store-apps.ps1 cannot be loaded because running scripts is di
    sabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135
    170.
    At line:1 char:1
    + C:\install\remove-store-apps.ps1
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : SecurityError: (:) [], PSSecurityException
        + FullyQualifiedErrorId : UnauthorizedAccess
    
    c:\Install>
    To run the script the execution policy has to be changed outside the script, in order for it to run.
    Do you have to run a script, for some reason? If not, don't use a script.

    Open PowerShell as administrator.
    Run the command: Get-AppxPackage -allusers | Remove-AppxPackage
      My Computer


  8. Posts : 102
    Windows 10 Pro
    Thread Starter
       #8

    Thanks! That worked.
      My Computer


  9. Posts : 2,450
    Windows 10 Pro x64
       #9

    Octopuss said:
    Thanks! That worked.

    You're very welcome!
      My Computer


  10. Posts : 2,450
    Windows 10 Pro x64
       #10

    If after all you need to run your script from a batch file, follow these steps:

    1. Create a file named RemoveStoreApps.bat, and place it wherever you want. It should contain the following line:
    Code:
    %comspec% /k PowerShell.exe -ExecutionPolicy Bypass -file "%SystemDrive%\install\remove-store-apps.ps1"

    2. The "%SystemDrive%\install\remove-store-apps.ps1" script should contain one line:
    Code:
    Get-AppxPackage -allusers | Remove-AppxPackage

    3. To run the batch file, right click on it and select "Run as Administrator."
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 04:34.
Find Us




Windows 10 Forums