1
1
using System ;
2
2
using System . Collections . Generic ;
3
+ using System . ComponentModel ;
3
4
using System . Diagnostics ;
4
5
using System . IO ;
5
6
using System . Linq ;
@@ -17,13 +18,21 @@ public partial class MainWindow : Form
17
18
private List < string > _listSystemApps = new List < string > ( ) ;
18
19
19
20
// General strings
20
- private string _successRemove = "Successfully removed:\n " ;
21
-
22
- private string _failedRemove = "Failed to remove:\n " ;
23
21
private readonly string _installCount = "My apps" ;
22
+
24
23
private readonly string _removeCount = "Remove apps" ;
25
24
private readonly string _nothingCount = "No apps to uninstall!" ;
26
25
26
+ // Community strings
27
+ private readonly string _uriPkg = "https://github.com/Sycnex/Windows10Debloater/raw/master/Windows10Debloater.ps1" ;
28
+ private readonly string _infoPkg = "This will download the PowerShell based Community version \" Windows10Debloater.ps1\" " +
29
+ "\n \n This is a interactive script with prompts which runs the following functions:" +
30
+ "\n - Debloat (a list of Bloatware that is removed can be viewed on the authors GitHub repository)" +
31
+ "\n - Removes registry keys leftover that are associated with the bloatware apps" +
32
+ "\n - Protect privacy by stopping some telemetry functions, stops Cortana from being used as your Search Index, disables unneccessary scheduled tasks, and more" +
33
+ "\n - Stop-EdgePDF" +
34
+ "\r \n \n Do you wish to continue?\r \n \n More information about this script can be found here https://github.com/Sycnex/Windows10Debloater" ;
35
+
27
36
// Update strings
28
37
private readonly string _releaseURL = "https://raw.githubusercontent.com/builtbybel/bloatbox/master/latest.txt" ;
29
38
@@ -36,7 +45,7 @@ public partial class MainWindow : Form
36
45
/// <summary>
37
46
/// Check for updates
38
47
/// </summary>
39
- private void CheckNewReleases_Click ( object sender , EventArgs e )
48
+ private void CheckUpdates_Click ( object sender , EventArgs e )
40
49
{
41
50
try
42
51
{
@@ -90,6 +99,9 @@ public MainWindow()
90
99
BtnClear . Text = "\ue894 " ; // Clear
91
100
}
92
101
102
+ /// <summary>
103
+ /// Retrieve UWP apps
104
+ /// </summary>
93
105
private void GetUWP ( )
94
106
{
95
107
LstUWP . Items . Clear ( ) ;
@@ -110,16 +122,22 @@ private void GetUWP()
110
122
string appInst = LstUWP . Items . ToString ( ) ;
111
123
foreach ( string item in LstUWPRemove . Items ) if ( item . Any ( appInst . Contains ) ) LstUWP . Items . Remove ( item ) ;
112
124
113
- RefreshInstalled ( ) ;
125
+ RefreshUWP ( ) ;
114
126
}
115
127
116
128
private void BtnRefresh_Click ( object sender , EventArgs e )
117
129
{
118
130
GetUWP ( ) ;
119
131
}
120
132
133
+ /// <summary>
134
+ /// App uninstaller
135
+ /// </summary>
121
136
private string RemoveUWP ( )
122
137
{
138
+ string success = "Successfully removed:\n " ;
139
+ string failed = "Failed to remove:\n " ;
140
+
123
141
foreach ( var item in LstUWPRemove . Items )
124
142
{
125
143
powerShell . Commands . Clear ( ) ;
@@ -132,32 +150,31 @@ private string RemoveUWP()
132
150
foreach ( var p in powerShell . Streams . Progress )
133
151
{
134
152
if ( p . Activity . Contains ( item . ToString ( ) ) && p . StatusDescription == "Completed" ) // Removed successfully
135
- {
136
- _successRemove += "\t " + item . ToString ( ) + "\n " ;
137
- // Console.WriteLine( _successRemove + item.ToString());
153
+ {
154
+ success += "\t " + item . ToString ( ) + "\n " ;
155
+ // Console.WriteLine(success + item.ToString());
138
156
break ;
139
157
}
140
158
else if ( p . Activity . Contains ( item . ToString ( ) ) && p . StatusDescription == "Error" ) // NOT removed
141
159
{
142
- if ( ! _failedRemove . Contains ( item . ToString ( ) ) ) _failedRemove += "\t " + item . ToString ( ) + "\n " ;
143
- // Console.WriteLine(_failedRemove + p.Activity);
144
- }
145
- }
146
-
147
- powerShell . Streams . Progress . Clear ( ) ;
148
-
149
- /* Detailed log OFF!
150
- if (powerShell.HadErrors) foreach (var p in powerShell.Streams.Error) { Console.WriteLine("\n\nERROR:\n" + p.ToString() + "\n\n"); } */
151
- }
152
-
153
- string outputPS = "" ;
154
- if ( powerShell . HadErrors ) { outputPS = _successRemove + "\n " + _failedRemove ; powerShell . Streams . Error . Clear ( ) ; }
155
- else { outputPS = _successRemove ; }
156
-
160
+ if ( ! failed . Contains ( item . ToString ( ) ) ) failed += "\t " + item . ToString ( ) + "\n " ;
161
+ // Console.WriteLine(failed + p.Activity);
162
+ }
163
+ }
164
+
165
+ powerShell . Streams . Progress . Clear ( ) ;
166
+ /* Detailed lof OFF
167
+ if (powerShell.HadErrors) foreach (var p in powerShell.Streams.Error) { Console.WriteLine("\n\nERROR:\n" + p.ToString() + "\n\n"); } */
168
+ }
169
+
170
+ string outputPS = "" ;
171
+ if ( powerShell . HadErrors ) { outputPS = success + "\n " + failed ; powerShell . Streams . Error . Clear ( ) ; }
172
+ else { outputPS = success ; }
173
+
157
174
return outputPS ;
158
175
}
159
176
160
- private void RefreshInstalled ( )
177
+ private void RefreshUWP ( )
161
178
{
162
179
int installed = LstUWP . Items . Count ;
163
180
int remove = LstUWPRemove . Items . Count ;
@@ -240,7 +257,7 @@ private void BtnAddAll_Click(object sender, EventArgs e)
240
257
// LstUWP.Items.Remove(item);
241
258
}
242
259
LstUWP . Items . Clear ( ) ;
243
- RefreshInstalled ( ) ;
260
+ RefreshUWP ( ) ;
244
261
}
245
262
246
263
private void BtnAdd_Click ( object sender , EventArgs e )
@@ -253,7 +270,7 @@ private void BtnAdd_Click(object sender, EventArgs e)
253
270
LstUWPRemove . Items . Add ( LstUWP . SelectedItem ) ;
254
271
LstUWP . Items . Remove ( LstUWP . SelectedItem ) ;
255
272
}
256
- RefreshInstalled ( ) ;
273
+ RefreshUWP ( ) ;
257
274
}
258
275
}
259
276
@@ -265,7 +282,7 @@ private void BtnRemoveAll_Click(object sender, EventArgs e)
265
282
// LstUWP.Items.Remove(item);
266
283
}
267
284
LstUWPRemove . Items . Clear ( ) ;
268
- RefreshInstalled ( ) ;
285
+ RefreshUWP ( ) ;
269
286
}
270
287
271
288
private void BtnRemove_Click ( object sender , EventArgs e )
@@ -278,7 +295,7 @@ private void BtnRemove_Click(object sender, EventArgs e)
278
295
LstUWP . Items . Add ( LstUWPRemove . SelectedItem ) ;
279
296
LstUWPRemove . Items . Remove ( LstUWPRemove . SelectedItem ) ;
280
297
}
281
- RefreshInstalled ( ) ;
298
+ RefreshUWP ( ) ;
282
299
}
283
300
}
284
301
@@ -307,11 +324,6 @@ private void LstUWPRemove_DoubleClick(object sender, EventArgs e)
307
324
BtnRemove_Click ( sender , e ) ;
308
325
}
309
326
310
- private void LnkMSSettingsAppsandfeatures_LinkClicked ( object sender , LinkLabelLinkClickedEventArgs e )
311
- {
312
- Process . Start ( "ms-settings:appsfeatures" ) ;
313
- }
314
-
315
327
private void LblMainMenu_Click ( object sender , EventArgs e )
316
328
{
317
329
this . MainMenu . Show ( Cursor . Position . X , Cursor . Position . Y ) ;
@@ -331,5 +343,55 @@ private void AppInfo_Click(object sender, EventArgs e)
331
343
"(C) 2020, Builtbybel (former Mirinsoft)" ,
332
344
"Info" , MessageBoxButtons . OK , MessageBoxIcon . Information ) ;
333
345
}
346
+
347
+ /// <summary>
348
+ /// Download optional community version Windows10Debloater.ps1
349
+ /// </summary>
350
+ private void LnkGetCommunityVer_LinkClicked ( object sender , LinkLabelLinkClickedEventArgs e )
351
+ {
352
+ if ( MessageBox . Show ( _infoPkg , this . Text , MessageBoxButtons . YesNo , MessageBoxIcon . Information ) == DialogResult . Yes )
353
+ {
354
+ PBar . Visible = true ;
355
+ var pkg = _uriPkg ;
356
+
357
+ try
358
+ {
359
+ WebClient wc = new WebClient ( ) ;
360
+ wc . DownloadProgressChanged += new DownloadProgressChangedEventHandler ( DownloadProgressChanged ) ;
361
+ wc . DownloadFileCompleted += new AsyncCompletedEventHandler ( Completed ) ;
362
+
363
+ wc . DownloadFileAsync ( new Uri ( pkg . Trim ( ) ) , @"Windows10Debloater.ps1" ) ;
364
+ }
365
+ catch ( Exception ex )
366
+ { MessageBox . Show ( ex . Message , this . Text ) ; }
367
+ }
368
+ }
369
+
370
+ public void DownloadProgressChanged ( Object sender , DownloadProgressChangedEventArgs e )
371
+ {
372
+ PBar . Value = e . ProgressPercentage ;
373
+ }
374
+
375
+ public void Completed ( object sender , AsyncCompletedEventArgs e )
376
+ {
377
+ try
378
+ {
379
+ var ps1File = @"Windows10Debloater.ps1" ;
380
+ var startInfo = new ProcessStartInfo ( )
381
+ {
382
+ FileName = "powershell.exe" ,
383
+ Arguments = $ "-NoProfile -ExecutionPolicy unrestricted -file \" { ps1File } \" ",
384
+ UseShellExecute = true ,
385
+ CreateNoWindow = true
386
+ } ;
387
+ Process . Start ( startInfo ) ;
388
+ PBar . Visible = false ;
389
+ }
390
+ catch ( Exception ex )
391
+ {
392
+ MessageBox . Show ( ex . Message , this . Text ) ;
393
+ PBar . Visible = false ;
394
+ }
395
+ }
334
396
}
335
397
}
0 commit comments