medicooey
medicooey
CC#
Created by medicooey on 12/24/2023 in #help
Creating Process as User from a Windows Service
I have a windows service that is meant to locate an active windows user token and run a process in their userspace. This seemed an easier path than doing something like named pipes; I want a service that executes a WPF app in the user session to prompt them to take action. Running into issues with my service though - when the service attempts to run a process as the user, I'm getting errors:
System.ArgumentNullException: SafeHandle cannot be null.
Happy to share the code, but just as happy to abandon this method and consider another. Challenge is we will never know the exact user we need to run this on; we want to be able to dpeloy this to any computer and have it function without knowing the users on the device. Task scheduler appears to be another mechanism, but I've not had luck figuring out how to get that to run in the user's space without knowing who the user is on any given device.
11 replies