Skip to content

Commit 47a4a4a

Browse files
committed
Bad fix for odd problem, can't seem to detect hybrid boots, causing computer to shut down on startup. This will handle the symptoms.
1 parent 3a6e02d commit 47a4a4a

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

IdleStartWatchdog/Service.cs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,19 @@ private void CheckStatus(object sender, ElapsedEventArgs elapsedEventArgs)
4545
else
4646
{
4747
var loggedOut = DateTime.Now - _lastTimeUserLoggedOut;
48-
if (loggedOut > Watchdog.Default.TimeToWait)
48+
49+
if (loggedOut > Watchdog.Default.TimeToWait.Add(Watchdog.Default.TimeToWait))
50+
{
51+
Log($"No-one has signed in after double the timeout, somethings wrong (hybrid boot?). Resetting timer.", EventLogEntryType.Error);
52+
_lastTimeUserLoggedOut = DateTime.Now;
53+
}
54+
else if (loggedOut > Watchdog.Default.TimeToWait)
4955
{
50-
Log($"No-one has signed in after {Watchdog.Default.TimeToWait.ToString()}, shutting down computer.", EventLogEntryType.Warning);
51-
ShutdownComputer();
56+
if (!_shutdownInitiated)
57+
{
58+
Log($"No-one has signed in after {Watchdog.Default.TimeToWait.ToString()}, shutting down computer.\nLast time someone signed out: {_lastTimeUserLoggedOut}", EventLogEntryType.Warning);
59+
ShutdownComputer();
60+
}
5261
}
5362
}
5463
}
@@ -84,15 +93,10 @@ private void Initialize()
8493

8594
private void ShutdownComputer()
8695
{
87-
if (_shutdownInitiated)
88-
{
89-
return;
90-
}
91-
9296
var psi = new ProcessStartInfo()
9397
{
9498
FileName = "shutdown",
95-
Arguments = "/s /t 0",
99+
Arguments = "/s /t 15",
96100
CreateNoWindow = true,
97101
UseShellExecute = false
98102
};

0 commit comments

Comments
 (0)