Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I had develop windows file watcher service to launch UI (as user give file print from menu) using createuserprocess winapi. It works fine for single user. For multi user this UI get launch in wrong user's session.

So I need launch UI in respective user's session

Any help appreciated

What I have tried:

I use .Net nuget Cassia library to get login user name, workstation, session id etc.

ITerminalServicesManager manager = new TerminalServicesManager();
using (ITerminalServer server = manager.GetLocalServer())
{
server.Open();
foreach (ITerminalServicesSession session in server.GetSessions())
{
Console.WriteLine("Hi there, " + session.UserAccount + " on session " + session.SessionId);
Console.WriteLine("It looks like you logged on at " + session.LoginTime +
" and are now " + session.ConnectionState);
}
}

But I am not able to get user sessionid who fire the file print (from menu option) command.
Posted
Updated 13-Jul-21 5:07am

1 solution

Save yourself the pain of this not working at all in future versions of Windows and create a small application that launches on user login. This app can "register" itself with the service application, receiving notification from it and launching whatever application it needs to or otherwise executes commands coming from the service.

Trying to launch an interactive application from a service is not guaranteed to work now, nor will it be in the future, because this is a security concern that can be patched out at any time.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900