-
Notifications
You must be signed in to change notification settings - Fork 0
/
Discord_Debloat.ps1
192 lines (160 loc) · 5.68 KB
/
Discord_Debloat.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# Check if the script is running as an Administrator
$adminTest = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
if (-not $adminTest) {
# Relaunch the script with Administrator privileges
Start-Process powershell.exe -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs
exit
}
# Define the base directory for Discord
$baseDir = "$env:LOCALAPPDATA\Discord"
# Function to safely remove files and folders
function Remove-Files {
param (
[string]$path,
[string[]]$fileNames
)
foreach ($fileName in $fileNames) {
$filePath = Join-Path -Path $path -ChildPath $fileName
if (Test-Path $filePath) {
Remove-Item -Path $filePath -Force -Recurse -ErrorAction SilentlyContinue
}
}
}
# Close Discord
Write-Host "Closing Discord!"
Stop-Process -Name discord -Force
# Define files to delete
$filesToDelete = @(
"discord_game_sdk_x64.dll",
"discord_game_sdk_x86.dll"
)
# Set Discord paths for updates file
$discordPath = "$env:USERPROFILE\AppData\Local\Discord"
Clear-Host
# Ask if user wants to disable updates
$disableUpdatesChoice = Read-Host "Would you like to disable updates completely? (Y/N)"
if ($disableUpdatesChoice -eq "Y") {
# Delete update-related files
$updatesToDelete = @(
"Update.exe",
"SquirrelSetup.log",
"Squirrel.exe"
)
Remove-Files -Path $discordPath -FileNames $updatesToDelete
Write-Host "Updates disabled!"
}
Clear-Host
# Ask if user wants to debloat Discord
$debloatChoice = Read-Host "Would you like to debloat your Discord? (Y/N)"
if ($debloatChoice -eq "Y") {
Write-Host "Removing bloat!"
# Directories to search in
$directoriesToSearch = @(
"C:\Path\To\Search",
"$env:LOCALAPPDATA\Discord"
)
# Search for and delete the specified files in each directory
foreach ($directory in $directoriesToSearch) {
Write-Host "Searching in directory: $directory"
foreach ($fileToDelete in $filesToDelete) {
$file = Get-ChildItem -Path $directory -Recurse -Filter $fileToDelete -File
if ($file -ne $null) {
Write-Host "File '$fileToDelete' found at: $($file.FullName)"
# Delete the file
Remove-Item -Path $file.FullName -Force -Recurse -ErrorAction SilentlyContinue
Write-Host "File deleted."
} else {
Write-Host "File '$fileToDelete' not found in $directory."
}
}
}
# List of directories to process
$directoriesToProcess = @(
"app-1.0.9001",
"app-1.0.9002",
"app-1.0.9003",
"app-1.0.9004",
"app-1.0.9005",
"app-1.0.9006",
"app-1.0.9007",
"app-1.0.9008",
"app-1.0.9010",
"app-1.0.9011",
"app-1.0.9012",
"app-1.0.9013",
"app-1.0.9014",
"app-1.0.9015",
"app-1.0.9016",
"app-1.0.9017",
"app-1.0.9018",
"app-1.0.9019",
"app-1.0.9020",
"app-1.0.9021",
"app-1.0.9022",
"app-1.0.9023",
"app-1.0.9024",
"app-1.0.9025",
"app-1.0.9026",
"app-1.0.9027",
"app-1.0.9028",
"app-1.0.9029",
"app-1.0.9030",
"app-1.0.9031",
"app-1.0.9032",
"app-1.0.9033",
"app-1.0.9034",
"app-1.0.9035"
# ... (add other directories)
)
$moduleFilesToRemove = @(
"discord_cloudsync-1",
"discord_dispatch-1",
"discord_erlpack-1",
"discord_game_utils-1",
"discord_media-1",
"discord_spellcheck-1",
"discord_krisp-1",
"discord_Spellcheck-1"
# ... (add other module files)
)
foreach ($directory in $directoriesToProcess) {
$modulePath = Join-Path -Path $baseDir -ChildPath "$directory\modules"
Remove-Files -path $modulePath -fileNames $moduleFilesToRemove -Force -Recurse -ErrorAction SilentlyContinue
}
Write-Host "Bloat removed!"
}
# ... (Rest of the script)
Clear-Host
# Ask if user wants to remove overlay
$removeOverlayChoice = Read-Host "Would you like to remove overlay? (Y/N)"
if ($removeOverlayChoice -eq "Y") {
Write-Host "Removing overlay!"
foreach ($directory in $directoriesToProcess) {
$modulePath = Join-Path -Path $baseDir -ChildPath "$directory\modules"
# Delete specified overlay files quietly
$overlayFilesToRemove = @(
"discord_rpc-1",
"discord_overlay2-1"
)
Remove-Files -path $modulePath -fileNames $overlayFilesToRemove -Force -Recurse -ErrorAction SilentlyContinue
}
Write-Host "Overlay removed!"
}
Clear-Host
# Open Discord executable location in Explorer
$directoriesToProcess | ForEach-Object {
$discordExePath = Join-Path -Path (Join-Path -Path $baseDir -ChildPath $_) -ChildPath "Discord.exe"
if (Test-Path $discordExePath) {
Start-Process -FilePath "explorer.exe" -ArgumentList "/select, `"$discordExePath`""
}
}
Write-Host "Everything done!"
Write-Host "WARNING!"
Write-Host "AFTER RUNNING THE SCRIPT YOU HAVE TO CREATE A DISCORD SHORTCUT"
Write-Host "FROM $($env:HOMEPATH)\AppData\Local\discord\app-0.0.(your version)!"
Write-Host "Credit goes to: Chrometastic and Velo!"
Write-Host "Created by: Matekoo!"
Write-Host "Krisp command created by iiiKariFPS!"
Write-Host "Go to $env:LOCALAPPDATA then your Discord folder and make a shortcut of your"
Pause
# ... (Rest of the script)