Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi run as different user

Tags:

cmd

winapi

delphi

I want a way in Delphi which I can run an exe file as a different user in order to gain different permissions. I do not want elevation of permissions. Screenshot:

enter image description here

I want from delphi code to start an application as a different user as depicted in the picture.

like image 863
Spyros Karavanis Avatar asked Jan 24 '14 10:01

Spyros Karavanis


People also ask

How to get Run as a different user?

Use Run As to start a program as another userLocate the program that you want to start in Windows Explorer, the Microsoft Management Console (MMC), or Control Panel. Press and hold down the SHIFT key while you right-click the .exe file or icon for the program, and then click Run as. Click The following user.

How to Run as a different user windows 11?

Run as different user from the taskbar context menuPress and hold the Shift key. While holding Shift , right-click the app name in the context menu to see extra menu items. Release the Shift key and click Run as different user. Finally, provide the user account data to run a new instance of the app from.


1 Answers

The API function that you are looking for is CredUIPromptForCredentials. This returns a username and password that you can pass to CreateProcessWithLogonW.

like image 53
David Heffernan Avatar answered Oct 05 '22 02:10

David Heffernan