Service to Logoff/Disconnect/Reboot Computer System
-
I have a service that will perform some kind of action depending on what the SessionChangeDescription is. The service is installed on a computer that autologs in. To make this happen this registry value needs to be set and is set during OnStart: Key: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon Value: AutoAdminLogon Data: 1 There is a Windows Form that will allow a domain user to log in and the service will change the AutoAdminLogon value to a 0. When a power outage occurs and power is restored the PC, the computer does not autologon cause the registry value AutoAdminLogon is not set back to a 1 yet. I normally just send a logoff, tsdiscon, or restart to the computer through SCCM and it will autolog again. These are my questions: 1. Is it possible to logoff or disconnect a session through the service at a logon screen? 2. Is it possible to trigger one of the SessionChangeDescription without any session changes? 3. Restart the computer through the service? What I have tried: At OnStart, get the AutoAdminLogon value and if it a 0, then do one of these: ExitWindowsEx function, WTSDisconnectSession function, wmi to logoff a session, tsdiscon.exe, logoff.exe, shutdown.exe, and LockWorkstation function. None of them work. If I do the same through SCCM, the computer autologs in.