As part of my Installshield project, I need to place some files in the user's Roaming app data folder (C:\Users\<Username>\AppData\Roaming\MyApp\MyFile
). For this I've created a component, and set its destination to [AppDataFolder]MyApp
.
While this works fine when I run as an Administrator, when I run the installer as a standard user (elevating the privileges during installation using the admin's account/password), MyFile
gets copied to the Administrator's roaming folder (C:\Users\<AdminUsername>\AppData\Roaming\MyApp\MyFile
), instead of the user's.
Is there a way around this?
Installing files to the user-profile is a problematic endeavor. Consider other approaches as explained here: Create folder and file on Current user profile, from Admin Profile.
That linked answer is somewhat over the top (it tries to summarize all the problems that can result from user-profile deployment), but basically you can have your application copy the file in question to the right user-profile folder on application launch for every user from a read-only template copy installed somewhere in the main application installation directory (under %ProgramFiles%).
Using the application to copy such files to the user-profile will eliminate a lot of deployment problems that can otherwise result. Please read the linked answer above for details.
As to what happens technically in your case, I am guessing that you have set a disk key-path for a per-user component. You need to set a HKCU registry path for such components if you want to avoid that erroneous link to the administrator folder.
UPDATE: Check if this explanation is better: http://forum.installsite.net/index.php?showtopic=21586#entry60600. By setting a HKCU path for the hosting component you won't get that hard coded name (erroneous) that is showing in red letters. Check the other answer below in the linked thread if the problem is still not clear.
If you chose to go down the HKCU key path approach, please read section 3: MSI Self-Repair
in the linked answer at the top above.