Windows 10: Updating .bat File, Removing Default Apps

Discus and support Updating .bat File, Removing Default Apps in Windows 10 Software and Apps to solve the problem; 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... Discussion in 'Windows 10 Software and Apps' started by SightUp, Nov 2, 2017.

  1. Bree New Member

    Updating .bat File, Removing Default Apps


    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.
     
  2. SightUp Win User

    So this is my .bat. Why do I get errors on each line?
     
    SightUp, Nov 2, 2017
    #17
  3. Bree New Member
    This is one of your lines...
    Code: PowerShell -Command "Get-appxprovisionedpackage –online | where-object {$_.packagename –like "*CandyCrushSodaSaga*"} | remove-appxprovisionedpackage –online"[/quote] 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...
    ...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"[/quote] nb. don't forget to run the .bat as Administrator.
     
  4. SightUp Win User

    Updating .bat File, Removing Default Apps

    I tried to changed everything you recommended. I am still getting errors. Do you see what is still wrong?
     
    SightUp, Nov 2, 2017
    #19
  5. SightUp Win User
    OK! I got it working.

    Some of them had this line appear under the code and some didn't. Is that a problem?
     
    SightUp, Nov 2, 2017
    #20
  6. lx07 Win User
    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 " -noNewLine; Write-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
    }
     
  7. SightUp Win User
    This is something new. What does it do specifically? Is that complete?
     
    SightUp, Nov 2, 2017
    #22
  8. lx07 Win User

    Updating .bat File, Removing Default Apps

    It is all from the tutorial really.

    As mentioned earlier in this thread Remove-AppxPackage removes for current user,
    Remove-AppxProvisionedPackage removes it for new user and deleting from %localappdata%\Packages deletes any caches for the current user.

    It certainly isn't complete. To be complete you would need to name all the apps you want to delete in the $apps array like this: PHP Code: $apps=
    @(
    "4DF9E0F8.Netflix"
    "9E2F88E3.Twitter"
    "A278AB0D.MarchofEmpires"
    "ClearChannelRadioDigital.iHeartRadio"
    "D52A8D61.FarmVille2CountryEscape"
    "Facebook.Facebook"
    "Flipboard.Flipboard"
    "KeeperSecurityInc.Keeper"
    "king.com.CandyCrushSaga"
    "king.com.CandyCrushSodaSaga"
    "king.com.ParadiseBay"
    "HoloCamera"
    "HoloItemPlayerApp"
    "HoloShell"
    "Microsoft.3DBuilder"
    "Microsoft.Appconnector"
    "Microsoft.BingFinance"
    "Microsoft.BingNews"
    "Microsoft.BingSports"
    #"Microsoft.BingWeather"
    "Microsoft.ConnectivityStore"
    "Microsoft.CommsPhone"
    "Microsoft.Getstarted"
    "Microsoft.Messaging"
    "Microsoft.Microsoft3DViewer"
    "Microsoft.MicrosoftOfficeHub"
    "Microsoft.MicrosoftSolitaireCollection"
    "Microsoft.MicrosoftStickyNotes"
    "Microsoft.MSPaint"
    "Microsoft.Office.OneConnect"
    #"Microsoft.Office.OneNote"
    "Microsoft.Office.Sway"
    "Microsoft.OneConnect"
    "Microsoft.People"
    "Microsoft.SkypeApp"
    "Microsoft.Windows.Phone"
    #"Microsoft.Windows.Photos"
    "Microsoft.WindowsAlarms"
    #"Microsoft.WindowsCalculator"
    #"Microsoft.WindowsCamera"
    #"Microsoft.WindowsFeedbackApp"
    "Microsoft.WindowsMaps"
    "Microsoft.WindowsPhone"
    "Microsoft.WindowsSoundRecorder"
    #"Microsoft.WindowsStore"
    "Microsoft.XboxApp"
    "Microsoft.XboxSpeechToTextOverlay"
    "Microsoft.XboxGameOverlay"
    "Microsoft.ZuneMusic"
    "Microsoft.ZuneVideo"
    #"microsoft.windowscommunicationsapps"
    "Microsoft.MinecraftUWP"
    "PandoraMediaInc.29680B314EFC2"
    "SlingTVLLC.SlingTV"
    "ShazamEntertainmentLtd.Shazam"
    "Windows.MircastView"
    )

    Write-Host "Removing default apps" -f yellow
    ForEach ($app in $apps) {
    Write-Host "Removing " -noNewLine; Write-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
    }

    It was more a suggestion that you had 3 areas to (consider) deleting.

    You could (I suppose) delete stuff from %localappdata% for other users but it would be complicated as you would have to take authority, save ACLs and restore authority back after.

    It would probably be easier to just run it for each user than mess with their permissions. Also PowerShell will not let you delete apps for another user - there may be a workaround for multi-user PCs but I don't know it.
     
Thema:

Updating .bat File, Removing Default Apps

Loading...
  1. Updating .bat File, Removing Default Apps - Similar Threads - Updating bat File

  2. Why can't I set a default App for .bat files?

    in Windows 10 Gaming
    Why can't I set a default App for .bat files?: I have read this question, as I also use vim for my editinghttps://answers.microsoft.com/en-us/windows/forum/all/how-do-i-set-default-app-for-filetypes-not-listed/b01cb589-f8e2-4186-a0f6-02ee0f15babeand searched and you can change the default open app for .bat files but have...
  3. Why can't I set a default App for .bat files?

    in Windows 10 Software and Apps
    Why can't I set a default App for .bat files?: I have read this question, as I also use vim for my editinghttps://answers.microsoft.com/en-us/windows/forum/all/how-do-i-set-default-app-for-filetypes-not-listed/b01cb589-f8e2-4186-a0f6-02ee0f15babeand searched and you can change the default open app for .bat files but have...
  4. remove default app by file type

    in Windows 10 Network and Sharing
    remove default app by file type: microsoft let the default app for .nds files internet explorer, does anyone know how to reset the default app for .nds files to none? https://answers.microsoft.com/en-us/windows/forum/all/remove-default-app-by-file-type/314aba23-2f40-4dea-bfa6-2b579a31194a
  5. remove default app by file type

    in Windows 10 Gaming
    remove default app by file type: microsoft let the default app for .nds files internet explorer, does anyone know how to reset the default app for .nds files to none? https://answers.microsoft.com/en-us/windows/forum/all/remove-default-app-by-file-type/314aba23-2f40-4dea-bfa6-2b579a31194a
  6. remove default app by file type

    in Windows 10 Software and Apps
    remove default app by file type: microsoft let the default app for .nds files internet explorer, does anyone know how to reset the default app for .nds files to none? https://answers.microsoft.com/en-us/windows/forum/all/remove-default-app-by-file-type/314aba23-2f40-4dea-bfa6-2b579a31194a
  7. Change default app with regedit or bat

    in Windows 10 Ask Insider
    Change default app with regedit or bat: We have a gpo which sets the default app for pdf's, we do not want to change this, except for when a user runs a bat script without admin rights. I have been trying to make a .bat file that would change the default pdf program to reader with; ftype...
  8. Remove default app by file type

    in Windows 10 Network and Sharing
    Remove default app by file type: I accidentally used notepad to open pcm files and now i cant get notepad off it how can i disable it like making it go back to saying choose a default https://answers.microsoft.com/en-us/windows/forum/all/remove-default-app-by-file-type/cd1b5fdf-c801-41aa-9e01-5938eaed3f8a
  9. Target removal through .bat file of remnant apps

    in Windows 10 Software and Apps
    Target removal through .bat file of remnant apps: I have comprised the following using the information provided on this site, a .bat file that removes all apps from local, other accounts and future accounts. Apps.zip However, upon launching CCleaner > Tools > Uninstall we have several remnants that are left behind we need...
  10. Adding the extra default apps to the .bat file.

    in Windows 10 Software and Apps
    Adding the extra default apps to the .bat file.: I have brought this up before. The present .bat commands are incomplete. I just reinstalled Windows 10 so I took a picture to show how I know and what I'd like to see updated, a before and after picture using CCleaner as it shows and allows you to uninstall what we cannot on...