Skip to content

Commit

Permalink
Further changes to service stop/uninstall behaviour
Browse files Browse the repository at this point in the history
- Fail uninstalling the service if it couldn't be stopped first

- Add error message to "Stop service" button if service failed to stop
  • Loading branch information
Sparronator9999 committed Sep 7, 2024
1 parent ef790ec commit 1103478
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions YAMDCC.GUI/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,12 @@ private void tsiStopSvc_Click(object sender, EventArgs e)

IPCClient.Stop();
Close();
Utils.StopService("yamdccsvc");

if (!Utils.StopService("yamdccsvc"))
{
MessageBox.Show("Failed to stop the YAMDCC service!",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}

Expand All @@ -379,24 +384,28 @@ private void tsiUninstall_Click(object sender, EventArgs e)
IPCClient.Stop();
Close();

if (!Utils.StopService("yamdccsvc"))
// Apparently this fixes the YAMDCC service not uninstalling
// when YAMDCC is launched by certain means
if (Utils.StopService("yamdccsvc"))
{
MessageBox.Show("Failed to stop the YAMDCC service!",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

if (Utils.UninstallService("yamdccsvc"))
{
// Only delete service data if the
// service uninstalled successfully
if (delData)
if (Utils.UninstallService("yamdccsvc"))
{
// Only delete service data if the
// service uninstalled successfully
if (delData)
{
Directory.Delete(DataPath, true);
}
}
else
{
Directory.Delete(DataPath, true);
MessageBox.Show("Failed to uninstall the YAMDCC service!",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show("Failed to uninstall the YAMDCC service!",
MessageBox.Show("Failed to stop the YAMDCC service!",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Expand Down

0 comments on commit 1103478

Please sign in to comment.