Skip to content

Commit

Permalink
uninstaller
Browse files Browse the repository at this point in the history
  • Loading branch information
TheArmagan committed Mar 9, 2023
1 parent b143143 commit de9fd79
Show file tree
Hide file tree
Showing 16 changed files with 96 additions and 3 deletions.
Binary file not shown.
Binary file not shown.
Binary file modified .vs/AcordStandaloneInstaller/v17/.suo
Binary file not shown.
19 changes: 16 additions & 3 deletions MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 80 additions & 0 deletions MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ void Install()
string discordRelease = GetSelectedDiscordRelease();

installButton.Text = "Installing..";
uninstallButton.Enabled = false;
installButton.Enabled = false;
releaseGroupBox.Enabled = false;
TopMost = true;
Expand Down Expand Up @@ -128,6 +129,7 @@ void Install()
}

installButton.Text = "Install Acord";
uninstallButton.Enabled = true;
installButton.Enabled = true;
releaseGroupBox.Enabled = true;
TopMost = false;
Expand All @@ -136,6 +138,79 @@ void Install()
if (resp == DialogResult.Yes) Close();
}

void Uninstall()
{
string discordRelease = GetSelectedDiscordRelease();

uninstallButton.Text = "Uninstalling..";
uninstallButton.Enabled = false;
installButton.Enabled = false;
releaseGroupBox.Enabled = false;
TopMost = true;

Process[] processes = Process.GetProcessesByName(discordRelease.ToLower()).ToArray();

string discordExePath = null;

for (int i = 0; i < processes.Length; i++)
{
Process process = processes[i];

try
{
process.Kill();
if (discordExePath == null)
{
discordExePath = process.MainModule.FileName;
Thread.Sleep(100);
}
}
catch
{

}

}

string[] appPaths = Directory.GetDirectories(Path.Combine(localAppData, discordRelease)).Where(i => Path.GetFileName(i).StartsWith("app-")).ToArray();

for (int i = 0; i < appPaths.Length; i++)
{
string discordAppPath = appPaths[i];

string modulesPath = Path.Combine(discordAppPath, "modules");

if (Directory.Exists(modulesPath))
{
string[] desktopCoreModulePaths = Directory.GetDirectories(modulesPath).Where(k => Path.GetFileName(k).StartsWith("discord_desktop_core-")).ToArray();

for (int j = 0; j < desktopCoreModulePaths.Length; j++)
{
string modulePath = Path.Combine(desktopCoreModulePaths[j], "discord_desktop_core");

File.WriteAllText(Path.Combine(modulePath, "index.js"), $@"module.exports = require(""./core.asar"");");
File.WriteAllText(Path.Combine(modulePath, "package.json"), "{\"name\":\"discord\",\"main\":\"index.js\",\"version\":\"0.0.0\"}");
}
}

}

if (discordExePath != null)
{
Thread.Sleep(100);
Process.Start(discordExePath);
}

uninstallButton.Text = "Uninstall Acord";
uninstallButton.Enabled = true;
installButton.Enabled = true;
releaseGroupBox.Enabled = true;
TopMost = false;

DialogResult resp = MessageBox.Show($"Uninstallation done for {discordRelease}! Do you want to exit installer?", "Acord Standalone Installer", MessageBoxButtons.YesNo);
if (resp == DialogResult.Yes) Close();
}

public void DownloadFile(string uri, string path)
{
using (var client = new WebClient())
Expand All @@ -148,5 +223,10 @@ private void installButton_Click(object sender, EventArgs e)
{
Install();
}

private void uninstallButton_Click(object sender, EventArgs e)
{
Uninstall();
}
}
}
Binary file modified bin/Debug/AcordStandaloneInstaller.exe
Binary file not shown.
Binary file modified bin/Debug/AcordStandaloneInstaller.pdb
Binary file not shown.
Binary file modified bin/Release/AcordStandaloneInstaller.exe
Binary file not shown.
Binary file modified bin/Release/AcordStandaloneInstaller.pdb
Binary file not shown.
Binary file modified obj/Debug/AcordStandaloneInstaller.csproj.GenerateResource.cache
Binary file not shown.
Binary file modified obj/Debug/AcordStandaloneInstaller.exe
Binary file not shown.
Binary file modified obj/Debug/AcordStandaloneInstaller.pdb
Binary file not shown.
Binary file not shown.
Binary file modified obj/Release/AcordStandaloneInstaller.exe
Binary file not shown.
Binary file modified obj/Release/AcordStandaloneInstaller.pdb
Binary file not shown.

0 comments on commit de9fd79

Please sign in to comment.