Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically Move a File to Program Files without Admin Rights?

Tags:

c#

I've got a very simple exe that downloads in a zip file with some other stuff. What I want to do is move one of those files to a location in program files. When I do this though, it says I don't have permissions unless I run it as admin. I don't always have this option. I doubt it, but is there anyway to do this without admin rights? This is all it's doing:

File.Copy(@"c:/file.txt", @"C:/Program Files (x86)/Folder/file.txt");
like image 777
KJ3 Avatar asked Dec 14 '25 20:12

KJ3


1 Answers

No, there is no way to do that unless you (as an admin) already set up access rights for your user to write to that directory. Normal access rights to Program Files will not let regular users write to that location, and there is no override.

One reason for this is to prevent viruses from infecting your system. Since Program Files is shared by all users, a file placed there may be executed by all users that log on to the system.

Also, it prevents badly written programs from saving settings in Program Files, which may affect/overwrite other users' settings.

like image 134
Joachim Isaksson Avatar answered Dec 16 '25 10:12

Joachim Isaksson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!