Exclude single file
We have a need with several packages to exclude a single file. In this case there is a .ini file that we need to exclude from the SVS package. We cannot exclude all .ini files as there are others that need to be part of the SVS package.
Here is what is happening.
An application has 2 .ini files. One (we'll call program.ini) is in Program Files and holds user settings for the program. We do not want this one as part of the virtual package because the users settings would all be lost upon reset. The Second file (we'll call setting.ini) is in the Windows folder and maintains some program specific connection strings. This file we do want as part of the virtual layer because other programs will sometimes overwrite this file and break the application. If it was part of the virtual layer then other programs would not be able to modify it and would have their own version.
I was able to use onPostImport events to copy the program.ini file to the physical layer. However any changes that the program makes to it are stored in the writeable layer instead of being part of the physical file. The only I know of to prevent this from happening is to exclude all .ini files. Which is not desirable since it would also break the setting.ini file.
The other problem we are having is the setting.ini file needs to be manually edited. If you edit it using notepad the changes are stored on the physical drive instead of in the writeable layer. I have seen posts on how to use svscmd to run notepad as part of the layer. That is going to cause a lot of confusion for people.
Surely there is some easier way to accomplish all of this.
I guess your users are local admins as otherwise whey wouldn't be able to modify the program.ini file, if they are normal users I would put this file some where under %APPDATA% if possible.
Is this the only .ini file located in the folder it resides? If so I would use a Data layer to store the file in instead.
If you use the onPostImport event to restore the program.ini file then make sure to copy it in the redirection area (Read-Only sublayer) instead. You could also use a OnPostReset event but that would required the user that triggeres the event to have permission for whatever the command performs.
If you need to edit a file part of the layer and you need to do this in the redirection area as notepad is placed in base (no layer). Yes you could use SVSCMD to execute notepad as part of the layer but that would place the edited file in the RW sublayer.
Users are Power Users not Local Admins. So they still have full write access to Program Files. The location of the file, like all program files, are not up for change since they are part of the application.
Can you explain how you would use the Data Layer option in this scenario?
I know you can edit files in the redirection area but that is a hard concept for users to understand. The thought of there being multiple versions of the same file in what looks like the same location is not something that many are grasping.
Create a Data layer and add the program.ini file to it.
Data layers has higher priority then application layers so any changes to this file will be stuck in the Data layer. Data layers cannot be reset but deleting the layer will remove the file of course.
Would you like to reply?
Login or Register to post your comment.