first of all - indeed, it is not allowed by the design to install and use the ClickOnce application as an administrator: http://msdn.microsoft.com/en-us/library/142dbbz4(v=vs.90).aspx
Take a look at this post: http://antscode.blogspot.ca/2011/02/running-clickonce-application-as.html - it explains how to launch the ClickOnce application as an administrator. BUT - he must say that I followed this path - and I was not lucky with him. I had numerous problems with this approach (trying to run the ClickOnce application as administrator). As far as I remember, the biggest problem was that automatic updating did not work properly. Not to mention that non-admin users may need to enter administrator credentials all the time.
Thus, I would advise rethinking your logic and encapsulating the part that needs to be done as an administrator in a separate EXE file , and to make it very understandable for the user, when he presses the THAT button, a UAC prompt will appear (maybe add a shield icon to the button ) And in this button_click event do something like this:
// 2. Run Photoshop action on this image (and wait for the task to complete) if (string.IsNullOrWhiteSpace(this.PhotoshopEnhanceActionAbsPath) == false) { var pi = new ProcessStartInfo(this.PhotoshopEnhanceActionAbsPath, "\"" + imgPhotoshopActionAbsPath + "\""); pi.UseShellExecute = true; pi.Verb = "runas"; var photoshopAction = Process.Start(pi); var success = photoshopAction.WaitForExit(); if (success == false) { // do something here } }
this approach worked very well for me. The key is here:
pi.UseShellExecute = true; pi.Verb = "runas";
it starts your EXE with administrator rights, so at that moment the UAC prompt will be displayed. Another nice consequence here is that users may not run this particular logic every time they use the application - and therefore they will not be annoyed with a hint when they do not need them.
source share