?
Solved

Problem with UAC when downloading a exe using WebClient

Posted on 2010-09-23
5
Medium Priority
?
845 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
While working, an annoying popup showing below will come and we cannot cancel or close it form the screen. The error message will come again and again.
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 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.
Suggested Courses
Course of the Month11 days, 16 hours left to enroll

752 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