2015-08-27 28 views
0

有人可以確認這個腳本是正確的。如何創建Powershell腳本Remove-appxpackage由批處理命令執行的Windows內置應用程序?

批量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 

而對於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 

以及如何添加等待時間在PowerShell中?

回答

1

是的,應該工作給定的腳本,並在確切的位置,並具有與批處理文件相同的名稱。我不知道爲什麼你想添加在PowerShell中的等待時間,但你正在尋找的cmdlet的是啓動睡眠

0

你可以把包在一個文本文件,這樣做:

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