This website uses cookies. By clicking OK, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Text file changes for registry files that include ...
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
DLee65
Pilgrim
- Mark as New
- Subscribe
- Mute
- Permalink
- Email to a Friend
- Report Inappropriate Content
May 14, 2014
01:06 PM
Text file changes for registry files that include path statements
I have included in my installation a .REG file that needs to be modified by the installer.
I have setup the text file replacement set and all works except for one thing, cases where the file includes a path statement.
For instance one name is 'InstallPath'='{InstallPath}'. This is the value I place as the 'Find What' value.
For the Replace with value I have "InstallPath"="[INSTALLDIR]"
After the app is installed the value reads: "InstallPath"="C:\Program Files\Amazing Charts\"
The problem here is that the .reg file expects double slashes. The path above should read "C:\\Program Files\\AmazingCharts\\"
I thought about inserting a step to replace single slashes with double slashes but that would break the hive path which uses single slashes.
Is there a way to handle this situation so that my .reg file is updated correctly?
Does the text file Find What filter utilize regular expressions at all?
Do I need to pass this process off to an InstallScript or C# custom action to update the file properly?
Thank you.
I have setup the text file replacement set and all works except for one thing, cases where the file includes a path statement.
For instance one name is 'InstallPath'='{InstallPath}'. This is the value I place as the 'Find What' value.
For the Replace with value I have "InstallPath"="[INSTALLDIR]"
After the app is installed the value reads: "InstallPath"="C:\Program Files\Amazing Charts\"
The problem here is that the .reg file expects double slashes. The path above should read "C:\\Program Files\\AmazingCharts\\"
I thought about inserting a step to replace single slashes with double slashes but that would break the hive path which uses single slashes.
Is there a way to handle this situation so that my .reg file is updated correctly?
Does the text file Find What filter utilize regular expressions at all?
Do I need to pass this process off to an InstallScript or C# custom action to update the file properly?
Thank you.
20 Replies
TurboFisch
Pilgrim
- Mark as New
- Subscribe
- Mute
- Permalink
- Email to a Friend
- Report Inappropriate Content
May 14, 2014
02:31 PM
Re: Text file changes for registry files that include path statements
I stopped using reg files for that reason. I just add the registry entry in the component's registry and set things like InstallLocation=[INSTALLDIR]
DLee65
Pilgrim
- Mark as New
- Subscribe
- Mute
- Permalink
- Email to a Friend
- Report Inappropriate Content
May 15, 2014
05:13 AM
Re: Text file changes for registry files that include path statements
Thank you for the input.
What I am trying to avoid is the installer executing just to write registry entries as a new user starts the application.
I am also trying to avoid having to touch NTUSER.DAT to handle the process.
I was hoping I could leverage the HKLM\Software\Microsoft\Active Setup key to write the key during login for each user.
What I am trying to avoid is the installer executing just to write registry entries as a new user starts the application.
I am also trying to avoid having to touch NTUSER.DAT to handle the process.
I was hoping I could leverage the HKLM\Software\Microsoft\Active Setup key to write the key during login for each user.
DLee65
Pilgrim
- Mark as New
- Subscribe
- Mute
- Permalink
- Email to a Friend
- Report Inappropriate Content
May 15, 2014
01:40 PM
Re: Text file changes for registry files that include path statements
I decided to create a vbscript custom action that will handle this process. It is scheduled for deferred execution after the event for updating the text files.
basically it does a replace for '\' to '\\' for all patterns that match ^Chr(34), basically a line that begins with a single quote character.
I then append all text to a variable and after reading through file, close the file, open the file for writing and then write the variable to file, essentially overwriting the original file.
This achieves our goals to eliminate the need for 'repair' to run for each new user that starts our application.
basically it does a replace for '\' to '\\' for all patterns that match ^Chr(34), basically a line that begins with a single quote character.
I then append all text to a variable and after reading through file, close the file, open the file for writing and then write the variable to file, essentially overwriting the original file.
This achieves our goals to eliminate the need for 'repair' to run for each new user that starts our application.

Flexera
- Mark as New
- Subscribe
- Mute
- Permalink
- Email to a Friend
- Report Inappropriate Content
May 16, 2014
09:32 AM
Re: Text file changes for registry files that include path statements
Rather than making a custom action that updates a file, I think it would be less work and thus safer to make a custom action that updates a copy of INSTALLDIR, say creating the double-backslash version in INSTALLDIR_REGFILE, and referencing INSTALLDIR_REGFILE instead of INSTALLDIR in text file changes.
RatBoyGL
Pilgrim
- Mark as New
- Subscribe
- Mute
- Permalink
- Email to a Friend
- Report Inappropriate Content
May 15, 2015
08:52 AM
Re: Text file changes for registry files that include path statements
DLee65
Pilgrim
- Mark as New
- Subscribe
- Mute
- Permalink
- Email to a Friend
- Report Inappropriate Content
May 15, 2015
10:01 AM
Re: Text file changes for registry files that include path statements
You are going to have to do what Michael suggested.
1. Create a new custom action that sets a new property like INSTALLDIR_DBLSEPARATOR and use this property for modifying your XML file.
I would use a simple vbscript as the custom action and use the Session.Property("INSTALLDIR").
Example:
I have NOT tested this code and I do not know if you need to escape the backslash, but this is the essence of what you need to do.
Then in your xml replace sequence use the property [INSTALLDIR_DBLSEPARATOR].
Hopefully this helps.
EDIT: You may want to use a regular expression too to test if the path already has double backslash, such as server paths, if that is even relevant to your case. Just thought I would bring it up just in case :). There are tons of examples of vbscript and regexp cases online if you get stuck.
1. Create a new custom action that sets a new property like INSTALLDIR_DBLSEPARATOR and use this property for modifying your XML file.
I would use a simple vbscript as the custom action and use the Session.Property("INSTALLDIR").
Example:
DIM propertyValue: propertyValue = Session.Property("INSTALLDIR")
DIM dlbSeparatorValue
dlbSeparatorValue = Replace(propertyValue, "\", "\\")
Session.Property("INSTALLDIR_DLBSEPARATOR") = dblSeparatorValue
I have NOT tested this code and I do not know if you need to escape the backslash, but this is the essence of what you need to do.
Then in your xml replace sequence use the property [INSTALLDIR_DBLSEPARATOR].
Hopefully this helps.
EDIT: You may want to use a regular expression too to test if the path already has double backslash, such as server paths, if that is even relevant to your case. Just thought I would bring it up just in case :). There are tons of examples of vbscript and regexp cases online if you get stuck.
RatBoyGL
Pilgrim
- Mark as New
- Subscribe
- Mute
- Permalink
- Email to a Friend
- Report Inappropriate Content
May 15, 2015
01:11 PM
Re: Text file changes for registry files that include path statements
DLee65.
I did something very close to this and now I am very close to having this fixed.
The problem now is, it is writing the path with a trailing \\ because INSTALLDIR has a trailing \
But in the config file I am editing, there is no trailing \
Not sure if there is a way to tell it to not put the trailing \\.
I have read this which has two different codes to remove the trailing backslash from InstallDir but I am not fluent enough in InstallShield to know how to implement this. https://flexeracommunity.force.com/customer/articles/en_US/HOWTO/Q106587
I did something very close to this and now I am very close to having this fixed.
The problem now is, it is writing the path with a trailing \\ because INSTALLDIR has a trailing \
But in the config file I am editing, there is no trailing \
Not sure if there is a way to tell it to not put the trailing \\.
I have read this which has two different codes to remove the trailing backslash from InstallDir but I am not fluent enough in InstallShield to know how to implement this. https://flexeracommunity.force.com/customer/articles/en_US/HOWTO/Q106587
rrinblue22
Pilgrim
- Mark as New
- Subscribe
- Mute
- Permalink
- Email to a Friend
- Report Inappropriate Content
May 18, 2015
04:26 AM
Re: Text file changes for registry files that include path statements
You would just use "StrRemoveLastSlash" InstallScript function to remove the trailing slash from the path.
RatBoyGL
Pilgrim
- Mark as New
- Subscribe
- Mute
- Permalink
- Email to a Friend
- Report Inappropriate Content
May 18, 2015
01:09 PM
Re: Text file changes for registry files that include path statements
So if I use this code:
[CODE]function set_prop()
STRING tmpINSTALLDIR;
STRING svInstalldir[256];
NUMBER nBuffer;
begin
tmpINSTALLDIR = INSTALLDIR;
nBuffer = 256;
StrRemoveLastSlash(tmpINSTALLDIR);
MsiSetProperty(ISMSI_HANDLE,'INSTALLDIR',tmpINSTALLDIR);
end[/CODE]
I have a few noob questions:
1) Do I just create a custom action and put this in?
2) If I remove the trailing back slash, are there ramifications elsewhere in the project that I need to account for?
3) How come when I add this InstallScript to my other scripts, it is not select-able when donig a new custom action based on install script? It doesn't appear in the drop down menu there.
Man this should not be this hard just to remove a back slash.
Right now, I have a custom action doing this: Session.Property("DOUBLE_INSTALLDIR") = Replace( Session.Property("INSTALLDIR"), "\", "\\" )
That is to make DOUBLE_INSTALLDIR have the value of INSTALLDIR with double slashes and it is working. But putting the trailing \\ on the end, which my config files do not have.
[CODE]function set_prop()
STRING tmpINSTALLDIR;
STRING svInstalldir[256];
NUMBER nBuffer;
begin
tmpINSTALLDIR = INSTALLDIR;
nBuffer = 256;
StrRemoveLastSlash(tmpINSTALLDIR);
MsiSetProperty(ISMSI_HANDLE,'INSTALLDIR',tmpINSTALLDIR);
end[/CODE]
I have a few noob questions:
1) Do I just create a custom action and put this in?
2) If I remove the trailing back slash, are there ramifications elsewhere in the project that I need to account for?
3) How come when I add this InstallScript to my other scripts, it is not select-able when donig a new custom action based on install script? It doesn't appear in the drop down menu there.
Man this should not be this hard just to remove a back slash.
Right now, I have a custom action doing this: Session.Property("DOUBLE_INSTALLDIR") = Replace( Session.Property("INSTALLDIR"), "\", "\\" )
That is to make DOUBLE_INSTALLDIR have the value of INSTALLDIR with double slashes and it is working. But putting the trailing \\ on the end, which my config files do not have.