Launch a WPF Application Using RunAs Prompt

So, I have a WPF application, and here is what I want to do. I can right-click on the executable file, select "Run as user" and get the "Windows Security" window with the username and password, as well as by logging into the smart card. I was wondering if there is a way to start Sysinternals Run as another user, to automatically open without right-clicking and select "Run as user". Any suggestions?

I was able to enter the Assembly manifest and make it work as an administrator, but that’s not what I need. I really need the option to run it with Smart Card credentials. Thank you in advance!

+4
source share
1 answer

AFAIK, the only way to do this is using the RunAs exefollowing. /savecredwill cache the credentials, but your user will still need to enter it the first time (which may annoy your use case).

runas.exe  /savecred /user:<localmachinename>\administrator "path to your WPF exe"

or if you are in a domain:

runas.exe  /savecred /user:<DomainName>\<AdministratorAccountName> "path to your WPF exe"

Example: to run Visual Studio 2012 in administrator mode, I tried the following and it worked. I was asked to enter the password only once, for the first time.

runas.exe  /savecred /user:<My_DomainName>\<My_AdministratorAccountName>  "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe"

Further reading: Runas documentation.

+1
source

All Articles