N-central Troubleshooting
Windows Agent shutdown and restart logic when using maintenance windows
Last Modified
Mon Nov 26 14:24 GMT 2018
Description
- This article provides information about the Shutdown/Restart logic agent is using for maintenance windows. This is provided to user for testing and informational purposes only in cases when there are Unexpected Shutdowns and non default events occurring in event viewer log after restart was done.
- This should help user better identify cause of the unexpected shutdown event.
Environment
- Windows N-able N-central Agent
Solution
Here is the shutdown logic that agent is using to do device restarts:
For Win8AndAbove:
command = " shutdown /g "
if (forceAppsShutdown) command += " /f /t 0
If above failed we call API:
[DllImport("advapi32.dll", SetLastError = true)]
private static extern Boolean InitiateSystemShutdown(
[MarshalAs(UnmanagedType.LPStr)] String ip,
[MarshalAs(UnmanagedType.LPStr)] String message,
Int32 timeout,
Boolean force,
Boolean reboot);
NOTE for Win8AndAbove: if user doesn't want to preserve application then we call
InitiateSystemShutdown API directly.
For anything before Win8:
[DllImport("advapi32.dll", SetLastError = true)]
private static extern Boolean InitiateSystemShutdown(
[MarshalAs(UnmanagedType.LPStr)] String ip,
[MarshalAs(UnmanagedType.LPStr)] String message,
Int32 timeout,
Boolean force,
Boolean reboot);