Service: log install/uninstall/start/stop/configure to the RemSound log
Local checkpoint - NOT for public release. ServiceAction and ConfigureServiceProfile now write to the main app's log (gated on RemSound logging), so turning on logs in RemSound captures the install request + result code and profile saves. (Windows also records the install itself in the System Event Log, Event 7045, always.) Gate 27/27. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
92ed477ddf
commit
941e0df99f
@@ -2244,6 +2244,7 @@ public sealed class MainForm : Form
|
|||||||
{
|
{
|
||||||
ServiceStore.SaveProfile(dlg.Result);
|
ServiceStore.SaveProfile(dlg.Result);
|
||||||
ServiceStore.SaveLoggingEnabled(dlg.ServiceLoggingEnabled);
|
ServiceStore.SaveLoggingEnabled(dlg.ServiceLoggingEnabled);
|
||||||
|
logFile.Event($"service: profile saved (service logging {(dlg.ServiceLoggingEnabled ? "on" : "off")})");
|
||||||
// Remove any stray copy the old design left in the user's profiles folder.
|
// Remove any stray copy the old design left in the user's profiles folder.
|
||||||
try { profileStore?.Delete(ServiceControl.ServiceProfileTitle); } catch { /* best-effort */ }
|
try { profileStore?.Delete(ServiceControl.ServiceProfileTitle); } catch { /* best-effort */ }
|
||||||
if (ServiceControl.Query() == ServiceState.Running)
|
if (ServiceControl.Query() == ServiceState.Running)
|
||||||
@@ -2268,7 +2269,9 @@ public sealed class MainForm : Form
|
|||||||
: "Uninstall the RemSound service?\n\nWindows will ask for administrator permission.";
|
: "Uninstall the RemSound service?\n\nWindows will ask for administrator permission.";
|
||||||
if (MessageBox.Show(this, msg, AppName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) return;
|
if (MessageBox.Show(this, msg, AppName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) return;
|
||||||
}
|
}
|
||||||
|
logFile.Event($"service: {label} requested (elevated)");
|
||||||
var rc = ServiceControl.RunElevated(verb);
|
var rc = ServiceControl.RunElevated(verb);
|
||||||
|
logFile.Event($"service: {label} finished with code {rc} ({(rc == 0 ? "success" : rc == -1 ? "cancelled/declined" : "failed")})");
|
||||||
if (rc == 0)
|
if (rc == 0)
|
||||||
MessageBox.Show(this, $"Service {label} succeeded.", AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
MessageBox.Show(this, $"Service {label} succeeded.", AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
else if (rc == -1)
|
else if (rc == -1)
|
||||||
|
|||||||
Reference in New Issue
Block a user