How to specify user credentials for an app with a click?

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

I'm talking about the application itself, not about the installer.

+6
installer credentials clickonce
source share
3 answers

The real answer is no, you should not do this. ClickOnce applications are installed under the user profile and belong only to that user. This will not and will not work as a custom installation.

Also note that if you double-click the [exe] file (the location of which changes with each update), it will not look for updates, it will not check the files to make sure t have been tampered with. In other words, it will not work as a ClickOnce application.

I also think that passing the username and password in the query string is not recommended, because anyone who runs the script or charles or any other network traffic sniffer will be able to see the credentials.

+2
source share

It is really possible, you just need to do it in two steps. First you will need to run ClickOnce ( dfsvc.exe ) as the user you are trying to portray, and then run the deployment application using rundll32 , something like this:

(from the command line)

1.- Press once:

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

2.- Run the application:

 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 run several applications, and after a while it will disappear as soon as you close all your fictitious clicks after the applications.

+18
source share

Are you talking about a single process or something that should happen every time your code runs on multiple computers? Because if you just want to personally run the ClickOnce application with higher permissions, it's pretty simple. Click once when applications are in% LOCALAPPDATA% \ Apps \ 2.0 [ObfuscatedFolderName]. Just find your application folder (the timestamp should be enough information), then right-click the EXE and run it as admin.

If you want to do this in code, the simplest solution is probably a shell application for your code that asks for elevated permissions in the code. Here is an example.

+1
source share

All Articles