The attached console app does not work when run by a Windows Service. We need to be able to read the MainWindowHandle property for all processes, for all users, when run by a service in the non-interactive desktop. Unfortunately, MainWindowHandle is always 0 as the service cannot interact with the desktop.
I am looking for a C# console application that returns the processes for all users. Unfortunately, the application MUST work when executed from the non-interactive desktop (Session ID 0). I need the Processes Name, SessionID, Path and Start Time. If possible, we should also return the product and product version.
I have written and uploaded a base skeleton of what I need, it works when run directly but does not provide the necessary information when run by a Windows Service. Windows, by design, prevents my Windows Service form interacting with the desktop. This meant that all processes had a MainWindowTitle of 0. I need to get all processes where MainWindowTitle != 0.
The resulting console app will be executed by a service running as LocalSystem. It is absolutely critical that the resulting application can read the MainWindowTitle property, so we only return processes with an active GUI.
Can someone help by fixing the attached console app project?