-
Notifications
You must be signed in to change notification settings - Fork 0
/
UPC.ps1
151 lines (133 loc) · 4.76 KB
/
UPC.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
Add-Type -AssemblyName PresentationFramework
# Define the list of apps to remove and their PowerShell commands
$apps = @{
'3D Builder' = '*3dbuilder*'
'Alarms & Clock' = '*windowsalarms*'
'Calculator' = '*windowscalculator*'
'Calendar & Mail' = '*windowscommunicationsapps*'
'Camera' = '*windowscamera*'
'Feedback Hub' = '*feedbackhub*'
'Get Help' = '*gethelp*'
'Groove Music' = '*zunemusic*'
'Maps' = '*windowsmaps*'
'Microsoft News' = '*bingnews*'
'Microsoft Solitaire Collection' = '*solitairecollection*'
'Movies & TV' = '*zunevideo*'
'OneNote' = '*onenote*'
'Paint 3D' = '*paint3d*'
'People' = '*people*'
'Photos' = '*photos*'
'Print 3D' = '*print3d*'
'Skype' = '*skype*'
'Snip & Sketch' = '*snipandsketch*'
'Sticky Notes' = '*stickynotes*'
'Tips' = '*getstarted*'
'Voice Recorder' = '*soundrecorder*'
'Weather' = '*bingweather*'
'Xbox' = '*xbox*'
'Your Phone' = '*yourphone*'
}
# Define the function to remove apps
function Remove-Apps {
$selectedApps = Get-SelectedApps
foreach ($app in $selectedApps) {
if ($apps[$app] -ne $null) {
Get-AppxPackage -AllUsers | Where-Object {$_.Name -like $apps[$app]} | Remove-AppxPackage -ErrorAction SilentlyContinue
}
}
[System.Windows.MessageBox]::Show('Apps removed successfully.', 'Success')
}
# Define the function to reinstall apps
function Reinstall-Apps {
foreach ($app in $apps.Keys) {
if ($apps[$app] -ne $null) {
Add-AppxPackage -Path "C:\Windows\SystemApps\$($app)\appxmanifest.xml" -ErrorAction SilentlyContinue
}
}
[System.Windows.MessageBox]::Show('Apps reinstalled successfully.', 'Success')
}
# Define the function to show the settings
function Show-Settings {
[System.Windows.MessageBox]::Show('No settings to show yet.', 'Settings')
}
# Define the function to get the selected apps
function Get-SelectedApps {
$selectedApps = @()
foreach ($child in $appsPanel.Children) {
if ($child.GetType().Name -eq 'CheckBox') {
$checkBox = [System.Windows.Controls.CheckBox]$child
if ($checkBox.IsChecked) {
$selectedApps += $checkBox.Content
}
}
}
return $selectedApps
}
# Create the WPF window
$window = New-Object System.Windows.Window
$window.Title = 'Windows 10 App Remover'
$window.SizeToContent = 'Height'
$window.Width = 500
$window.ResizeMode = 'CanMinimize'
$window.WindowStartupLocation = 'CenterScreen'
# Create the main stack panel
$stackPanel = New-Object System.Windows.Controls.StackPanel
$stackPanel.Margin = '10'
$stackPanel.HorizontalAlignment = 'Left'
# Create the title label
$titleLabel = New-Object System.Windows.Controls.Label
$titleLabel.Content = 'Select the apps to remove:'
$titleLabel.FontSize = '16'
$titleLabel.Margin = '0 0 0 10'
$stackPanel.Children.Add($titleLabel)
# Create the scroll viewer
$scrollViewer = New-Object System.Windows.Controls.ScrollViewer
$scrollViewer.VerticalScrollBarVisibility = 'Auto'
$scrollViewer.HorizontalScrollBarVisibility = 'Disabled'
$scrollViewer.Margin = '0 5 0 5'
$scrollViewer.MaxHeight = 250
$scrollViewer.Content = $appsPanel
$stackPanel.Children.Add($scrollViewer)
# Create the apps panel
$appsPanel = New-Object System.Windows.Controls.StackPanel
$appsPanel.HorizontalAlignment = 'Left'
# Create the checkboxes
foreach ($app in $apps.Keys) {
$checkBox = New-Object System.Windows.Controls.CheckBox
$checkBox.Content = $app
$checkBox.Margin = '0 0 0 5'
$appsPanel.Children.Add($checkBox)
}
$scrollViewer.Content = $appsPanel
# Create the button panel
$buttonPanel = New-Object System.Windows.Controls.StackPanel
$buttonPanel.Orientation = 'Horizontal'
$buttonPanel.HorizontalAlignment = 'Right'
$buttonPanel.Margin = '0 10 0 0'
# Create the Remove button
$removeButton = New-Object System.Windows.Controls.Button
$removeButton.Content = 'Remove'
$removeButton.Margin = '0 0 5 0'
$removeButton.Add_Click({
Remove-Apps
})
$buttonPanel.Children.Add($removeButton)
# Create the Reinstall button
$reinstallButton = New-Object System.Windows.Controls.Button
$reinstallButton.Content = 'Reinstall'
$reinstallButton.Margin = '0 0 5 0'
$reinstallButton.Add_Click({
Reinstall-Apps
})
$buttonPanel.Children.Add($reinstallButton)
# Create the Settings button
$settingsButton = New-Object System.Windows.Controls.Button
$settingsButton.Content = 'Settings'
$settingsButton.Add_Click({
Show-Settings
})
$buttonPanel.Children.Add($settingsButton)
$stackPanel.Children.Add($buttonPanel)
# Add the stack panel to the window and show it
$window.Content = $stackPanel
$window.ShowDialog() | Out-Null