How can I replicate Task Manager's switch user functionality in C#?

114 Views Asked by At

I have a basic application that runs in the tray, and I'd like to incorporate the Task Manager's switch user functionality into it. This will be used to switch between a local "regular" user and a domain admin, both of which are mine.

Basically, instead of bringing up Task Manager, going to Users, right clicking on a user and clicking Connect, I want to make the process more efficient by simply right clicking on my tray icon, hover Users and click on the user you want to connect to.

Obviously I'm not looking to bypass any credentials - upon clicking the user, ideally it'd invoke the same popup you get in Windows when it asks for that users password.

Is this even possible? It should be noted that the application itself is running as a domain admin.

Thanks in advance.

1

There are 1 best solutions below

2
On

Simply pinvoke the LockWorkStation function.