views:

137

answers:

1

I am updating an existing application that is installed via a Setup and Deployment Project.

The old application copied a config and a database file into the application's folder in Program Files during installation. This worked fine on Win 2000 and Win Xp (under a local admin account). In Windows 7, however, not only is this frowned upon, but it essentially doesn't work due to UAC.

So I want to update the application to write its config/data in CommonApplicationData. In the existing Setup and Deployment project, you can easily select some locations as targets for copying files. i.e. Application Folder, User's Desktop, & User's Program Files.

I do not see an analogous means of telling the Setup program to copy to the AppData / CommonApplicationData folders. Does that exist, and if not, are there any simple fixes?

Thanks!

A: 

Do a Right Click | Add Special Folder | Custom Folder and name it anything you want ( Common Application Data Folder would be good )

In the folder properties grid, change the DefaultLocation attribute to [CommonAppDataFolder].

Add a file to the folder, build and install. You should find your file in C:\ProgramData on Windows 7.

Be advised, I highly reccomend other tools such as InstallShield and WiX over Visual Studio Deployment Projects. The tool is very limited in what it can do and you will eventually hit a brick wall.

Christopher Painter
This worked well for the most part, but I added some files inside of a directory, including a database file. I'm able to write to new files within the folder fine, and to overwrite existing files, but the database says it is read only. Any thoughts there?
turtle
MS-DOS style Read-Only ( attrib +R ) or NTFS ACL read only? ( User doesn't have permissions ) ( btw, this is really a new question )
Christopher Painter
Sorry. I sort of agree, but it is strongly related, I think. Using the above method, I can create the files and folders, however it appears that the folders are created as read-only for standard users, which seems to go against the point of using the app data folder. Is there a way to edit the above method so that the setup and deployment project creates the folders as writable to a standard user?
turtle
You asked how to deploy files to CommonApplicationData folder, you didn't ask if that folder had default write permissions for standard users. Windows provides no such well known folder to my knowledge which I've always thought strange.Windows Installer can change the folder permissions via the LockPermissions table but Visual Studio Deployment Projects don't expose that. Remember my warning about the brick wall? For a simple solution move these files to a WiX v3 merge module and use WiX's Permission element. Then consume this merge module in your VDRPOJ install.
Christopher Painter
This is like refactoring an EXE to an EXE and DLL and leads to better code maintainability over the long run and the merge module now represents a single responsibility and the MSI isn't overly concerned ( God Class ).
Christopher Painter