Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # UWPAppRemover (c) Wasif Hasan | Aug 2020
- $signature1 = @'
- public static void ShowConsoleWindow(int state)
- {
- var handle = GetConsoleWindow();
- ShowWindow( handle, state );
- }
- [System.Runtime.InteropServices.DllImport("kernel32.dll")]
- static extern IntPtr GetConsoleWindow();
- [System.Runtime.InteropServices.DllImport("user32.dll")]
- static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
- '@
- $hideconsole = Add-Type -MemberDefinition $signature1 -Name Hide -Namespace HideConsole -ReferencedAssemblies System.Runtime.InteropServices -PassThru
- $hideconsole::ShowConsoleWindow(0)
- Add-Type -AssemblyName System.Windows.Forms
- Add-Type -AssemblyName System.Drawing
- $all_uwpapps = "3D Viewer,Advertising,Alarms and Clock,Bing integration,Bubble Witch 3 Saga,Calculator,Calendar,Camera,Feedback Hub,Get Help,Get Started,Groove Music,Mail,Maps,Microsoft News,Microsoft Solitare Collection,Minecraft UWP,Mixed Reality Portal,Movies and TV,Office Online,OneNote Online,Office Lens,Paint 3D,People,Photos,Skype,Snip and Sketch,Sticky Notes,Tips,To Do,Video Editor,Voice Recorder,Weather,Xbox and Game bar,Wallet,Your Phone" -split ","
- $def_uwpapps = "3D Viewer,Advertising,Alarms and Clock,Bing integration,Bubble Witch 3 Saga,Calendar,Camera,Feedback Hub,Get Help,Get Started,Groove Music,Maps,Microsoft News,Microsoft Solitare Collection,Minecraft UWP,Mixed Reality Portal,Office Lens,Paint 3D,People,Snip and Sketch,Sticky Notes,Tips,To Do,Video Editor,Voice Recorder,Weather,Xbox and Game bar,Wallet,Your Phone" -split ","
- $appx = [ordered]@{"3D Viewer" = "Microsoft.Microsoft3DViewer"; "Advertising" = "Microsoft.Advertising.Xaml*"; "Alarms and Clock" = "Microsoft.WindowsAlarms"; "Bing integration" = "Microsoft.Bing*"; "Bubble Witch 3 Saga" = "king.com.BubbleWitch3Saga"; "Calculator" = "Microsoft.WindowsCalculator"; "Calendar" = "Microsoft.Calendar"; "Camera" = "Microsoft.WindowsCamera"; "Feedback Hub" = "Microsoft.WindowsFeedbackHub"; "Get Help" = "Microsoft.GetHelp"; "Get Started" = "Microsoft.Getstarted"; "Groove Music" = "Microsoft.Zune*"; "Mail" = "Microsoft.Mail"; "Maps" = "Microsoft.WindowsMaps"; "Microsoft News" = "Microsoft.News"; "Microsoft Solitare Collection" = "Microsoft.MicrosoftSolitaireCollection"; "Minecraft UWP" = "Microsoft.MinecraftUWP"; "Mixed Reality Portal" = "Microsoft.MixedReality.Portal"; "Movies and TV" = "Microsoft.MoCamera"; "Office Online" = "Microsoft.MicrosoftOfficeHub"; "OneNote Online" = "Microsoft.Office.OneNote"; "Office Lens" = "Microsoft.Office.Lens"; "Paint 3D" = "Microsoft.MSPaint"; "People" = "Microsoft.People"; "Photos" = "Microsoft.Windows.Photos"; "Skype" = "Microsoft.SkypeApp"; "Snip and Sketch" = "Microsoft.ScreenSketch"; "Sticky Notes" = "Microsoft.MicrosoftStickyNotes"; "Tips" = "Microsoft.HelpAndTips"; "To Do" = "*Todo*"; "Video Editor" = "Microsoft.VP9VideoExtensions"; "Voice Recorder" = "Microsoft.VoiceRecorder"; "Weather" = "*Weather*"; "Xbox and Game bar" = "Microsoft.Xbox*"; "Wallet" = "Microsoft.Wallet"; "Your Phone" = "Microsoft.YourPhone"}
- $top=20;$left=50
- $f = New-Object System.Windows.Forms.Form
- $f.Text = "Select UWP apps to remove"
- $f.StartPosition = "CenterScreen"
- $f.Size = New-Object System.Drawing.Size(400,850)
- $all_uwpapps | Foreach {
- $c = $_.split(" ") -join "_"
- $top += 20
- iex "`$$($c) = New-Object System.Windows.Forms.CheckBox;`$$($c).Top = $($top);`$$($c).Left = $($left);`$$($c).Anchor='Left,Top';`$$($c).Parent='';`$$($c).Text='$($_)';`$$($c).Autosize=`$true;if('$_' -in `$def_uwpapps){`$$c.Checked=`$true};`$f.Controls.Add(`$$c)"
- }
- $ok=New-Object System.Windows.Forms.Button;$ok.Text='OK';$ok.Top=770;$ok.Left=290
- $ok.add_click({$f.Close()});$f.Controls.AddRange($ok)
- $sa=New-Object System.Windows.Forms.Button;$sa.Text='Select All';$sa.Top=770;$sa.Left=200
- $sa.add_click({$f.Controls | Where-Object {($_.Checked) -or !($_.Checked)} | Foreach {try{$_.Checked=$True}catch{}}});$f.Controls.AddRange($sa)
- $null = $f.ShowDialog()
- $choices = $f.Controls | Where-Object {$_.Checked} | Select-Object -ExpandProperty Text
- $choices | Foreach {Get-AppxPackage $appx."$_" | Select-Object -ExpandProperty Name}
- Read-Host
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement