Repository navigation
Expand file tree
/
Copy pathMainForm.Persistence.cs
More file actions
55 lines (52 loc) · 2.21 KB
/
Copy pathMainForm.Persistence.cs
File metadata and controls
55 lines (52 loc) · 2.21 KB
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
namespace Argus;
internal sealed partial class MainForm
{
/// <summary>"Keeps coming back": show what restarts the program and let the user switch each starter off.</summary>
private void ShowPersistenceDialog(Finding f)
{
ShowMain();
using var d = new PersistenceDialog(f);
d.ShowDialog(this);
switch (d.Outcome)
{
case PersistOutcome.Changed:
_watcher.ResolveRespawn(f, dontAskAgain: false);
break;
case PersistOutcome.LeaveAlone:
_watcher.ResolveRespawn(f, dontAskAgain: true);
Log.Write($"{f.ProcName}: left alone; Argus will not suggest disabling what restarts it again.");
break;
case PersistOutcome.RestartAsAdministrator:
RestartAsAdministrator();
break;
}
}
/// <summary>"What restarts it?": look for the service, task or startup entry behind the selected program without waiting for it to come back three times.</summary>
private void ShowStarters()
{
var f = Selected().FirstOrDefault(x => x.Category != Category.Blocker);
if (f == null)
{
MessageBox.Show(this, "Select a program in the list first.", "Argus", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
Finding? r;
var old = Cursor; Cursor = Cursors.WaitCursor; // reading Task Scheduler can take a second
try { r = f.Category == Category.Respawn ? f : Persistence.FindingFor(f.ProcName, f.Path); }
finally { Cursor = old; }
if (r == null)
{
MessageBox.Show(this,
$"No service, scheduled task or startup entry points at {f.ProcName}.\n\nIf it comes back, something else starts it (an installer, an updater, " +
"or another program), or it is a core Windows program, which Argus never offers to switch off.",
"Argus", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
ShowPersistenceDialog(r);
}
private void ShowDisabledByArgus()
{
using var d = new DisabledByArgusDialog();
d.ShowDialog(this);
}
}