简体   繁体   中英

How to Create Powershell Script Remove-appxpackage Windows Built-in App Executed by Batch Command?

Can someone confirm that this script are correct.

Batch cmd Execute.bat :

@echo off
color d
echo Execute Powershell Script With Administrative Privileges
echo.
PowerShell.exe -NoProfile -Command "& {Start-Process PowerShell.exe -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""%~dpn0.ps1""' -Verb RunAs}"
echo.
timeout /t 5

And for Powerhsell.ps1 :

Remove-appxpackage Microsoft.XboxApp_5.6.17000.0_x64__8wekyb3d8bbwe

Remove-appxpackage Microsoft.XboxGameCallableUI_1000.10240.16384.0_neutral_neutral_cw5n1h2txyewy

Remove-appxpackage Microsoft.XboxIdentityProvider_1000.10240.16384.0_neutral_neutral_cw5n1h2txyewy

Remove-appxpackage Windows.ContactSupport_10.0.10240.16384_neutral_neutral_cw5n1h2txyewy

Remove-appxpackage Microsoft.BingNews_4.3.193.0_x86__8wekyb3d8bbwe

Remove-appxpackage Microsoft.BingFinance_4.3.193.0_x86__8wekyb3d8bbwe

Remove-appxpackage Microsoft.BingWeather_4.3.193.0_x86__8wekyb3d8bbwe

Remove-appxpackage Microsoft.Getstarted_2.1.9.0_x64__8wekyb3d8bbwe

Remove-appxpackage Microsoft.SkypeApp_3.2.1.0_x86__kzf8qxf38zg5c

Remove-appxpackage Microsoft.WindowsPhone_10.1506.20010.0_x64__8wekyb3d8bbwe

Remove-appxpackage Microsoft.WindowsMaps_4.1505.50619.0_x64__8wekyb3d8bbwe

Remove-appxpackage Microsoft.People_1.10159.0.0_x64__8wekyb3d8bbwe

Remove-appxpackage Microsoft.Office.OneNote_17.4201.10091.0_x64__8wekyb3d8bbwe

Remove-appxpackage Microsoft.MicrosoftSolitaireCollection_3.1.6103.0_x64__8wekyb3d8bbwe

Remove-appxpackage Microsoft.MicrosoftOfficeHub_17.4218.23751.0_x64__8wekyb3d8bbwe

Remove-appxpackage Microsoft.BingSports_4.3.193.0_x86__8wekyb3d8bbwe

Remove-appxpackage Microsoft.Appconnector_1.3.3.0_neutral__8wekyb3d8bbwe

Remove-appxpackage Microsoft.3DBuilder_10.0.0.0_x64__8wekyb3d8bbwe

Remove-appxpackage microsoft.windowscommunicationsapps_17.6002.42251.0_x64__8wekyb3d8bbwe

And how to add wait time in powershell?

Yes that should work given that the script and is in the exact location and has the same name as the batch file. I'm not sure why you are wanting to add a wait time in PowerShell, but the cmdlet that you are looking for is start-sleep

You could put the packages in a text file and do this:

$packages = Get-Content c:\scripts\packages.txt
Foreach ($package in $packages){
 Remove-appxpackage $package
  Start-Sleep -Seconds 15 #change this as needed
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM