2

I have a program designed to work in XP, but with Windows dropping support for the OS, it's time to upgrade.

The location is in Program Files(x86), so when I run it without Admin privileges, it can't read/write library/assembly files within its folder.

What are my options?

Found this link helpful:

Allow access permission to write in Program Files of Windows 7

Community
  • 1
  • 1
DTavaszi
  • 192
  • 1
  • 10
  • What are these 'library files'? Are they class libraries (.dll's)? Or something else. – Chris Dunaway Oct 28 '13 at 15:30
  • 1
    You could create a ClickOnce installer, [here's a good blog post](http://www.c-sharpcorner.com/uploadfile/37db1d/deploying-wpf-application-with-clickonce-deployment-techniques/) on the subject. – JMK Oct 28 '13 at 15:31
  • @ChrisDunaway They're assembly files in the same directory as the program. – DTavaszi Oct 28 '13 at 15:38
  • @JMK Does it apply to Windows Form? – DTavaszi Oct 28 '13 at 15:39
  • 1
    Sure does, [here's a more relevant link](http://stackoverflow.com/a/2365481/969613), [and another one](http://msdn.microsoft.com/en-us/library/wh45kb66(v=vs.90).aspx) – JMK Oct 28 '13 at 15:41
  • How are you accessing the libraries then? If they're just assemblies referenced by the main application, you shouldn't be having any problems with the assemblies. Does the code in the assemblies try to create files under Program Files? – Chris Dunaway Oct 28 '13 at 16:08
  • Yeah, the assemblies write some files. I was a bit ambiguous but by access I meant both read/write. – DTavaszi Oct 28 '13 at 16:11

1 Answers1

7

Since Vista was released in 2007, UAC has meant that users do not have rights to write to the program files directory, unless the program is run elevated. You need to locate the files that need to be modified somewhere else.

Exactly where those files should be located, I cannot say. Perhaps under the user profile, perhaps somewhere else. It would require some detailed knowledge of how your application operates to give more specific advise. And quite possible your application will need some re-design in order to work well with UAC.

On the other hand, you say that your application can't access library files within its folder. If all you are trying to do is read these library files, there will be no problem, even in modern versions of Windows. It seems plausible that you have not yet fully diagnosed the problem. It seems likely that your application is trying to write to a restricted location. But reading library or assembly files should be fine, even with restricted access under UAC.

So perhaps the problem is not the reading of these library files. Perhaps the problem is that your application is writing to the program files directory, or some other restricted location. You'll need to do a little debugging to diagnose exactly which parts of your application are failing.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • Is writing to C:\ fine? (not accessing any Windows subdirectories) – DTavaszi Oct 28 '13 at 15:34
  • 3
    No, under Vista and later, you cannot create files or directories in C:\ without elevation. What's more, you should not even be contemplating doing that. – David Heffernan Oct 28 '13 at 15:35
  • There is indeed some writing going on, but those files don't really matter where they are, as long as they're in a common place (not user/documents). I was hoping for a way the Admin can give privilege to the program to run as standard user... As the user doesn't decide what file gets created/modified. There's no such thing, is there? – DTavaszi Oct 28 '13 at 15:47
  • 1
    You would probably store them under an application specific sub-folder of `Environment.SpecialFolders.CommonApplicationData`. You'll need your installer to add a permissive ACL to that sub-folder. – David Heffernan Oct 28 '13 at 15:48