Solved

Problem with UAC when downloading a exe using WebClient

Posted on 2010-09-23
5
832 Views
Last Modified: 2013-12-16
Hi,

I'm using this to download a application (exe) from the web:
webClient = new WebClient();
webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);
webClient.DownloadFileAsync(new Uri(downloadpath), file);

This works fine if UAC is disabled and also when UAC is enabled as long my application is not installed to the "Program Files".
If UAC is enabled and my app try to download an exe using the WebClient fiddler doesn't show any action that I try to download anything (so no error message for sure).
In case I download a zip archive anything works fine ...

Is there a workaround to let the WebClient download an exe also when UAC is enabled and the downloading app is installed to the "Program Files"?

Thanks

Andre
0
Comment
Question by:andre72
5 Comments
 
LVL 11

Expert Comment

by:rowansmith
ID: 33742688
You need to download the file to a location that the user has access too.  Such as the DOWNLOADS directory or the TEMP directory.

-Rowan
0
 

Author Comment

by:andre72
ID: 33751954
And why is it possible to download a zip archive but not an exe?
0
 
LVL 14

Expert Comment

by:systan
ID: 33759804
try to adjust you virus realtime protection to permissive not aggressive.
0
 
LVL 14

Expert Comment

by:systan
ID: 33759807
try to adjust your ANTI virus software realtime protection to permissive not aggressive.
0
 
LVL 29

Accepted Solution

by:
nffvrxqgrcfqvvc earned 500 total points
ID: 33769602
<< Is there a workaround to let the WebClient download an exe also when UAC is enabled and the downloading app is installed to the "Program Files"? >>
You can download the file but as already mentioned you don't have write access to Program Files location. This doesn't mean you can't still download a file to another directory that allows write access which was already mentioned in the first post by rowansmith. You're trying to "download" to your executable location which won't work if it's located in the Program Files directory unless you use one of these options.
1) Change the "download" location to a location that has write access which typically is Public Documents and can be shared by all users.
2) Use Com Elevation to request the administrative token. (This is the BEST option because it can run sections of code in a surrogate process with elevated permissions. The best part is your application still runs at the AsInvoker level.)
3) Create a seperate executable that is manifested with (RequireAdministrator)  adding the download code to this process and setup command line parameters to pass url,filename then from your main application shell the executable to elevate the process so it has permissions to write into Program Files.
4) Manifest your main application with RequireAdministrator (The worst option if your application doesn't always need administrative rights. This will ask the user to run your application elevated each time they open the application.)

 
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

I recently purchased an HP EliteBook 2540p notebook/laptop. It has two video ports on it – VGA and DisplayPort. HP offers an optional docking station for the 2540p that also has both a VGA port and a DisplayPort. There are numerous online reports do…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum editing capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now