-1

as you know, C:\Program Files is a restricted folder and Only administrators can modify the contents of this folder. my c# application has ability to update him self. so i need to download some files programmatically from server and replace them with old files. those files are in Program Files. what can i do about it?

2 Answers2

1

You're pretty stuck, if you need to have your application run anywhere that requires Administrator privilege to update. You are forced to elevate your process's privilege to administrator level to perform your update.

A solution to this problem is to install your application somewhere else--someplace that does not require administrator privilege.

Russ
  • 4,091
  • 21
  • 32
0

You are going to need to spawn a helper application, that will escalate to get the appropriate permissions, copy the new binary where it needs to go, and exits. Perhaps you can use copy.exe in conjunction with a Process.Start that knows to escalate. This SO article seems to indicate you can do it without too much trouble. However, there is no way around the admin rights if your program lives in C:\Program Files

Community
  • 1
  • 1
Pete Garafano
  • 4,863
  • 1
  • 23
  • 40