Merge claudedo/ebd5a205ecfe40c298e3995f9f92f0a1
This commit is contained in:
@@ -16,6 +16,11 @@ public sealed class RegisterAutostartStep : IInstallStep
|
||||
if (!File.Exists(workerExe))
|
||||
return StepResult.Fail($"Worker executable not found: {workerExe}");
|
||||
|
||||
// Legacy service/task cleanup below runs unconditionally on every install/update/repair,
|
||||
// even though it's a no-op once migrated. A cached "already migrated" flag could go stale
|
||||
// (e.g. a user re-adds the legacy service) and strand them with it still running; two
|
||||
// extra process starts per run is the price for that migration safety net.
|
||||
|
||||
// 1) Migrate away the legacy Windows service if present.
|
||||
progress.Report("Checking for legacy worker service...");
|
||||
var (queryExit, _) = await ProcessRunner.RunAsync("sc.exe", $"query {LegacyServiceName}", null, progress, ct);
|
||||
@@ -38,10 +43,11 @@ public sealed class RegisterAutostartStep : IInstallStep
|
||||
await ProcessRunner.RunAsync("schtasks.exe", $"/Delete /TN \"{LegacyTaskName}\" /F", null, progress, ct);
|
||||
|
||||
// 3) Register per-user autostart via a Startup-folder shortcut.
|
||||
progress.Report("Creating Startup shortcut...");
|
||||
progress.Report("Checking Startup shortcut...");
|
||||
try
|
||||
{
|
||||
AutostartShortcut.Install(AutostartShortcut.DefaultStartupDir, workerExe);
|
||||
var created = AutostartShortcut.Install(AutostartShortcut.DefaultStartupDir, workerExe);
|
||||
progress.Report(created ? "Startup shortcut created." : "Startup shortcut already up to date.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user