AFAIK, the only way to do this is using the RunAs exe
following. /savecred
will 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.
source
share