Skip to content

Commit

Permalink
Bad fix for odd problem, can't seem to detect hybrid boots, causing c…
Browse files Browse the repository at this point in the history
…omputer to shut down on startup. This will handle the symptoms.
  • Loading branch information
squid-box committed Jan 11, 2017
1 parent 3a6e02d commit 47a4a4a
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions IdleStartWatchdog/Service.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,19 @@ private void CheckStatus(object sender, ElapsedEventArgs elapsedEventArgs)
else
{
var loggedOut = DateTime.Now - _lastTimeUserLoggedOut;
if (loggedOut > Watchdog.Default.TimeToWait)

if (loggedOut > Watchdog.Default.TimeToWait.Add(Watchdog.Default.TimeToWait))
{
Log($"No-one has signed in after double the timeout, somethings wrong (hybrid boot?). Resetting timer.", EventLogEntryType.Error);
_lastTimeUserLoggedOut = DateTime.Now;
}
else if (loggedOut > Watchdog.Default.TimeToWait)
{
Log($"No-one has signed in after {Watchdog.Default.TimeToWait.ToString()}, shutting down computer.", EventLogEntryType.Warning);
ShutdownComputer();
if (!_shutdownInitiated)
{
Log($"No-one has signed in after {Watchdog.Default.TimeToWait.ToString()}, shutting down computer.\nLast time someone signed out: {_lastTimeUserLoggedOut}", EventLogEntryType.Warning);
ShutdownComputer();
}
}
}
}
Expand Down Expand Up @@ -84,15 +93,10 @@ private void Initialize()

private void ShutdownComputer()
{
if (_shutdownInitiated)
{
return;
}

var psi = new ProcessStartInfo()
{
FileName = "shutdown",
Arguments = "/s /t 0",
Arguments = "/s /t 15",
CreateNoWindow = true,
UseShellExecute = false
};
Expand Down

0 comments on commit 47a4a4a

Please sign in to comment.