forked from vecerap/uup-custom-app-list-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-uup-custom-app-list.ps1
127 lines (110 loc) · 3.25 KB
/
generate-uup-custom-app-list.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
$seed = get-random
$code = @"
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
namespace WinStoreAppBuilder
{
public static class Program$seed
{
private const string TEXT_FILE = "CustomAppsList.txt";
private const string CONFIG_FILE = "ConvertConfig.ini";
private const string ORIGINAL_PREFIX = "original-";
private static string[] _apps = new string[]
{
"WindowsStore",
"StorePurchaseApp",
"SecHealthUI",
"DesktopAppInstaller",
"Windows\\.Photos",
"WindowsCamera",
"WindowsNotepad",
"Microsoft\\.Paint",
"Microsoft\\.WindowsTerminal",
"MicrosoftWindows\\.Client\\.WebExperience",
"Microsoft\\.WindowsCalculator",
"Microsoft\\.ScreenSketch",
"windowscommunicationsapps",
"Microsoft\\.GetHelp",
"XboxSpeechToTextOverlay",
"XboxGameOverlay",
"XboxIdentityProvider",
"QuickAssist",
"ApplicationCompatibilityEnhancements",
"MicrosoftWindows\\.CrossDevice",
"Microsoft\\.ZuneMusic",
"Microsoft\\.YourPhone",
"Microsoft\\.GamingApp",
"Microsoft\\.XboxGamingOverlay",
"Microsoft\\.Xbox\\.TCUI",
"Microsoft\\.WebMediaExtensions",
"Microsoft\\.RawImageExtension",
"Microsoft\\.HEIFImageExtension",
"Microsoft\\.HEVCVideoExtension",
"Microsoft\\.VP9VideoExtensions",
"Microsoft\\.WebpImageExtension",
"Microsoft\\.DolbyAudioExtensions",
"Microsoft\\.AVCEncoderVideoExtension",
"Microsoft\\.MPEG2VideoExtension",
"Microsoft\\.AV1VideoExtension"
};
public static void Main()
{
if (!File.Exists(TEXT_FILE))
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Custom app list not found.");
Console.ResetColor();
return;
}
if(File.Exists(ORIGINAL_PREFIX + TEXT_FILE)) {
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Original file was already modified");
Console.ResetColor();
return;
}
var lines = File.ReadAllLines(TEXT_FILE);
var regex = BuildRegex();
var list = new List<string>();
foreach(var line in lines)
{
var match = Regex.Match(line, regex);
if (match.Success)
{
string newLine = line.Replace("# ", string.Empty);
list.Add(newLine);
} else
{
list.Add(line);
}
}
File.Move(TEXT_FILE, ORIGINAL_PREFIX + TEXT_FILE);
File.WriteAllLines(TEXT_FILE, list, Encoding.UTF8);
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Custom app list generated. Original file was kept...");
EnableCustomList();
Console.WriteLine("Custom list enabled in config");
Console.ResetColor();
}
private static string BuildRegex()
{
StringBuilder sb = new StringBuilder();
sb.Append("(");
string apps = string.Join("|", _apps);
sb.Append(apps);
sb.Append(")");
return sb.ToString();
}
private static void EnableCustomList()
{
var config = File.ReadAllText(CONFIG_FILE);
var newConfig = config.Replace("CustomList =0", "CustomList =1");
File.WriteAllText(CONFIG_FILE, newConfig, Encoding.UTF8);
}
}
}
"@
Add-Type -TypeDefinition $code -Language CSharp
Invoke-Expression "[WinStoreAppBuilder.Program$seed]::Main()"