Geeks With Blogs

News



Add to Google

Tim Hibbard CEO for EnGraph software

Clarification - The specific program I am working with here has the word "updater" in the name.  This flags the UAC that it needs admin rights.  Full Trust ClickOnce plays nicely with UAC otherwise.

I've been battling all day with how one of our ClickOnce applications works with the UAC in Vista.  I've found two ways to get past the "Cannot Start Application" message:

Cannot Start Application ClickOnce

Run IE as an administrator

The first way is very painful and not useful for a repeatable process, but it works.  Assume your ClickOnce application lives at http://mycompany.com/ClickOnceApp.application.


1)  Browse to C:\Program Files\Internet Explorer
2)  Right click ieplore.exe
3)  Select "Run as an administrator"
4)  Click "Allow" on the UAC prompt
5)  Type "http://mycompany.com/ClickOnceApp.application" in the address bar and press enter

Create a Windows Forms application that request administrative rights

The second way still isn't pretty, but it's better.

1)  Create a Windows Forms application called ClickOnceShell
2)  Replace all the code in static void Main() with

System.Diagnostics.Process.Start("c:\\Program Files\\Internet Explorer\\iexplore.exe", "http://mycompany/ClickOnceApp.application");

3)  Build ClickOnceShell.exe
4)  Browse to \ClickOnceShell\Bin\Debug
5)  Right click on ClickOnceShell.exe and select "Properties"
6)  Select the "Compatibility" tab, check "Run this program as an administrator" and press "OK"
7)  Double click ClickOnceShell.exe
8)  Click "Allow" on the UAC prompt

Basically, our ClickOnceShell application has administrative rights, so when it starts the IE process, IE is granted administrative rights.  So our ClickOnce application is able to start properly.

Also, we can't say Process.Start("http://mycompany...") because:
1)  The user's default browser might not be IE
2)  If the user already has an instance of IE7 open, it will want to open the URL in a second tab.  Our application will then fail because that instance of IE7 isn't running with administrative rights.

I really just need to drill into the permissions of our ClickOnce applications and see if I can make it work without full trust, but it's nice to know that we have options for our clients as they begin to install Vista.

Update - Read this post for a clean way to start a process with admin rights

Technorati tags: , ,
Posted on Thursday, January 18, 2007 2:52 PM EnGraph , .NET , Vista , ClickOnce | Back to top


Comments on this post: Full Trust ClickOnce and Vista UAC

# re: Full Trust ClickOnce and Vista UAC
Requesting Gravatar...
wtf is this crap??
Left by sfgs on Jan 24, 2009 8:32 AM

# re: Full Trust ClickOnce and Vista UAC
Requesting Gravatar...
Thanks, was implementing a similar solution and it didn't work half the time, it's because I was launching it without calling IE.exe and passing the url as arguments.
Left by Tony on Mar 08, 2010 1:10 PM

# re: Full Trust ClickOnce and Vista UAC
Requesting Gravatar...
Thanks for the article...
I am using the shell application option with process start :

Dim theProcessStart = New ProcessStartInfo(My.Settings.AppLocation)
theProcessStart.UseShellExecute = True
Dim theProcess = New Process
theProcess.StartInfo = theProcessStart
theProcess.Start()

It works well when connected to the internet however the app needs to run without internet too... without connection IE throws a connection error and the execution stops... the clickonce shortcut seem to run just fine without connection.
Does anyone knows how to make it work when not connected to the net?
Thanks!!
Left by wuzup on Dec 14, 2010 6:03 PM

Your comment:
 (will show your gravatar)


Copyright © Tim Hibbard | Powered by: GeeksWithBlogs.net