Solved

Problem with UAC when downloading a exe using WebClient

Posted on 2010-09-23
5
836 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Unknown Windows 7 64-bit Screen Appearance 5 37
Where did System.Data.Objects go? 2 23
Internet Protocol Security question 3 66
Help with preventing downloading a zip file 10 35
If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This Micro Tutorial will teach you how to the overview of Microsoft Security Essentials. This is a free anti-virus software that guards your PC against viruses, spyware, worms, and other malicious software. This will be demonstrated using Windows…
This Micro Tutorial will teach you how to change your appearance and customize your Windows 7 interface to your unique preference. This will be demonstrated using Windows 7 operating system.

816 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

10 Experts available now in Live!

Get 1:1 Help Now