How to specify user credentials for a click-once application?

Vitalik picture Vitalik · Aug 31, 2010 · Viewed 8.6k times · Source

For a regular .exe file i can always right click and select "run as..". How can i run a Click-Once application under different credentials in a similar way?

I am talking about the application itself, not the installer.

Answer

Alan picture Alan · Aug 17, 2012

This is actually possible, you just need to do it in two steps. First you'll need to launch ClickOnce (dfsvc.exe) as the user you are trying to impersonate and then you can launch the deploy application using rundll32, something like this:

(From the command line)

1.- Click once:

runas /user:domain\user "c:\Windows\Microsoft.NET\Framework\v4.0.30319\dfsvc.exe"

2.- Launch app:

runas /user:domain\user "rundll32 c:\Windows\System32\dfshim.dll,ShOpenVerbApplication http://someurl.com/tool.application"

Note that you only need to run dfsvc.exe once if you need to launch multiple apps and it will go away after a while once you close all your impersonated click once applications.