File Security in Windows Vista with the .NET Installer

I am trying to write an installer (creating a .vdproj) that will work on both Windows Vista and XP. The only thing I find is that when I try to run it on Vista, the files I include in the installer are installed with read-only permissions for the Users groups. This is a problem because the application needs to read / write from these files. The only way I was able to get it to work was by either "Run as administrator" or by changing permissions. Does anyone know how to make these files available to anyone who needs to write? Thank.

+1


source to share


2 answers


The Program Files folder and its contents are readable by standard users only. This is by design, and you will find that this also applies to Windows XP. It's just that in Windows XP, all so many people are running with administrator privileges all the time that you could get away with it. If you ever want to distribute your application in a business environment, you'll soon find that it won't work on XP either.

The solution is NOT to put files in the executable if standard users need write access. Instead, place them in the application data folder. For most xp machines this will be:
C: \ Documents and Settings \ All Users \ Application Data \ Your App



However, this will not always be the case, and it is slightly different from Vista anyway, so make sure you get this path through the mechanism provided by your programming environment. In .Net, you can use a function Environment.GetFolderPath()

.

+6


source


To add some detail to Joel's answer:

  • In Win2K and XP CSIDL_APPDATA should be used for each user roaming . On Vista, this is FOLDERID_RoamingAppData.

  • In Win2K and XP CSIDL_LOCAL_APPDATA should be used for a user, no roaming . In Vista, this is FOLDERID_LocalAppData.

  • In Win2K and XP CSIDL_COMMON_APPDATA should be used for every machine , that is, for all users of the application. On Vista, this is FOLDERID_ProgramData.



NB This last folder is usually read-only for non-non-permissive users. The recommended solution for this is to create a read / write subfolder during application installation.

EDIT. To get the actual locations of these constants on a specific computer using managed code, try System.Environment.GetFolderPath with the constants defined here . Another helpful link: here .

+1


source







All Articles