Updating .bat File, Removing Default Apps

Page 2 of 3 FirstFirst 123 LastLast

  1. Posts : 194
    Windows 10
    Thread Starter
       #11

    "PowerShell -Command "

    Is that the right thing? Or is that just the normal PowerShell?
      My Computer


  2. Posts : 31,594
    10 Home x64 (22H2) (10 Pro on 2nd pc)
       #12

    A .bat file runs in the command prompt environment: cmd.exe. From a command prompt you can run the normal powershell. If you type powershell in a command prompt window it runs poweshell until you type 'exit' to close powershell.

    Each line in your .bat file is calling powershell and passing a command line for it to execute. If you run the .bat in a 'Command Prompt (Admin)' it should also run the powershell commands as administrator (which is required for them to work).
      My Computers


  3. Posts : 194
    Windows 10
    Thread Starter
       #13

    Bree said:
    A .bat file runs in the command prompt environment: cmd.exe. From a command prompt you can run the normal powershell. If you type powershell in a command prompt window it runs poweshell until you type 'exit' to close powershell.

    Each line in your .bat file is calling powershell and passing a command line for it to execute. If you run the .bat in a 'Command Prompt (Admin)' it should also run the powershell commands as administrator (which is required for them to work).
    This is the same as right clicking and running as admin.
      My Computer


  4. Posts : 31,594
    10 Home x64 (22H2) (10 Pro on 2nd pc)
       #14

    SightUp said:
    This is the same as right clicking and running as admin.
    That should work too. The point is the .bat has to run in an elevated command processor in order to be able to run powershell at an elevated level.
      My Computers


  5. Posts : 194
    Windows 10
    Thread Starter
       #15

    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*3dbuilder*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*windowsalarms*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*Appconnector*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*Asphalt8Airborne*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*windowscalculator*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*windowscommunicationsapps*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*windowscamera*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*CandyCrushSodaSaga*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*DrawboardPDF*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*Facebook*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*BethesdaSoftworks.FalloutShelter*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*FarmVille2CountryEscape*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*WindowsFeedbackHub*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*GetHelp*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*officehub*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*skypeapp*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*getstarted*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*zunemusic*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*windowscommunicationsapps*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*windowsmaps*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*Messaging*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*solitairecollection*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*Wallet*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*ConnectivityStore*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*MinecraftUWP*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*bingfinance*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*zunevideo*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*Netflix*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*bingnews*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*onenote*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*OneConnect*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*MSPaint*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*PandoraMediaInc*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*people*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*CommsPhone*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*windowsphone*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*photos*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*WindowsScan*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*SkypeApp*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*bingsports*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*MicrosoftStickyNotes*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*windowsstore*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*Office.Sway*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*getstarted*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*Twitter*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*Microsoft3DViewer*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*soundrecorder*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*bingweather*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*xboxapp*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*XboxGameOverlay*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*XboxIdentityProvider*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*XboxOneSmartGlass*"} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*XboxSpeechToTextOverlay*"} | remove-appxprovisionedpackage –online"
    So this is my .bat. Why do I get errors on each line?
      My Computer


  6. Posts : 31,594
    10 Home x64 (22H2) (10 Pro on 2nd pc)
       #16

    SightUp said:
    So this is my .bat. Why do I get errors on each line?
    This is one of your lines...
    Code:
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*CandyCrushSodaSaga*"} | remove-appxprovisionedpackage –online"
    I copied it, saved it to a .bat and tried to run it. I got errors too. In fact, there are two problems.

    First, look very carefully at each occurrence of –online. That is not a 'minus' sign (as it should be) at the beginning, It should look like this : -online (note the almost imperceptible difference between the and - characters). I'm not surprised you didn't spot it. Just find and replace all with - and it will work. (There's also a wrong before like.)

    It looks like this problem may be in the code lines as copied from @Brink's tutorial,

    The second problem is the use of the " quotes character. You have put quotes around the command to pass to powershell, but the command itself uses the " quotes character around the *packagename* bit. As written in your command line, only the part of the command between the first pair of quotes is passed to powershell. Effectively the command is interpreted as...
    PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "
    ...the remainder of the line is being ignored.

    To correct that you need to use two different 'quote' delimiters. Use ' instead of " around each *packagename*.

    So, a working (and tested) version of your line above with both errors corrected is...
    Code:
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*CandyCrushSodaSaga*'} | remove-appxprovisionedpackage -online"
    nb. don't forget to run the .bat as Administrator.
      My Computers


  7. Posts : 194
    Windows 10
    Thread Starter
       #17

    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*3dbuilder*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*windowsalarms*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*Appconnector*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*Asphalt8Airborne*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*windowscalculator*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*windowscommunicationsapps*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*windowscamera*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*CandyCrushSodaSaga*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*DrawboardPDF*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*Facebook*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*BethesdaSoftworks.FalloutShelter*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*FarmVille2CountryEscape*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*WindowsFeedbackHub*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*GetHelp*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*officehub*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*skypeapp*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*getstarted*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*zunemusic*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*windowscommunicationsapps*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*windowsmaps*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*Messaging*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*solitairecollection*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*Wallet*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*ConnectivityStore*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*MinecraftUWP*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*bingfinance*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*zunevideo*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*Netflix*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*bingnews*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*onenote*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*OneConnect*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*MSPaint*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*PandoraMediaInc*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*people*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*CommsPhone*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*windowsphone*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*photos*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*WindowsScan*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*SkypeApp*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*bingsports*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*MicrosoftStickyNotes*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*windowsstore*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*Office.Sway*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*getstarted*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*Twitter*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*Microsoft3DViewer*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*soundrecorder*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*bingweather*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*xboxapp*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*XboxGameOverlay*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*XboxIdentityProvider*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*XboxOneSmartGlass*'} | remove-appxprovisionedpackage –online"
    PowerShell -Command "Get-appxprovisionedpackage -online | where-object {$_.packagename -like '*XboxSpeechToTextOverlay*'} | remove-appxprovisionedpackage –online"
    I tried to changed everything you recommended. I am still getting errors. Do you see what is still wrong?
      My Computer


  8. Posts : 194
    Windows 10
    Thread Starter
       #18

    OK! I got it working.

    Path :
    Online : True
    RestartNeeded : False
    Some of them had this line appear under the code and some didn't. Is that a problem?
      My Computer


  9. Posts : 5,478
    2004
       #19

    SightUp said:
    Some of them had this line appear under the code and some didn't. Is that a problem?
    No, it is normal.

    If something was removed you get it. If it wasn't (for example you try to remove a package that doesn't exist) you don't.

    You could consider deleting the junk from %appdata% as well. This is what I do:
    PHP Code:
            ForEach ($app in $apps) {    
                
    Write-Host "Removing " -noNewLineWrite-Host $app -f white

                
    # Need to hide the progress bar as otherwise it remains on the screen            
                
    $ProgressPreference="SilentlyContinue"
                
                
    Get-AppxPackage -Name $app -AllUsers Remove-AppxPackage

                $ProgressPreference
    ="Continue"

                
    Get-AppXProvisionedPackage -Online |
                    
    where DisplayName -EQ $app |
                    
    Remove-AppxProvisionedPackage -Online
                        
                $appPath
    ="$Env:LOCALAPPDATA\Packages\$app*"
                
    Remove-Item $appPath -Recurse -Force -ErrorAction 0            
            

      My Computer


  10. Posts : 194
    Windows 10
    Thread Starter
       #20

    lx07 said:
    No, it is normal.

    If something was removed you get it. If it wasn't (for example you try to remove a package that doesn't exist) you don't.

    You could consider deleting the junk from %appdata% as well. This is what I do:
    PHP Code:
            ForEach ($app in $apps) {    
                
    Write-Host "Removing " -noNewLineWrite-Host $app -f white

                
    # Need to hide the progress bar as otherwise it remains on the screen            
                
    $ProgressPreference="SilentlyContinue"
                
                
    Get-AppxPackage -Name $app -AllUsers Remove-AppxPackage

                $ProgressPreference
    ="Continue"

                
    Get-AppXProvisionedPackage -Online |
                    
    where DisplayName -EQ $app |
                    
    Remove-AppxProvisionedPackage -Online
                        
                $appPath
    ="$Env:LOCALAPPDATA\Packages\$app*"
                
    Remove-Item $appPath -Recurse -Force -ErrorAction 0            
            

    This is something new. What does it do specifically? Is that complete?
      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 06:27.
Find Us




Windows 10 Forums