This website uses cookies. By clicking Accept, 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
- :
- Re: Text file changes for registry files that include path statements
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- 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
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 14, 2014
02:31 PM
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]
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 15, 2014
05:13 AM
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.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 15, 2014
01:40 PM
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.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 16, 2014
09:32 AM
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.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 15, 2015
08:52 AM
I am having the same issue with trying to edit an XML .config file.
The file, by default, has a file path with double slashes.
If I set it to INSTALLDIR in the red outlined box, it just puts the install path with single slashes instead of double.
Can anyone advize a way around this?
The file, by default, has a file path with double slashes.
If I set it to INSTALLDIR in the red outlined box, it just puts the install path with single slashes instead of double.
Can anyone advize a way around this?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 15, 2015
10:01 AM
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.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 15, 2015
01:11 PM
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
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 18, 2015
04:26 AM
You would just use "StrRemoveLastSlash" InstallScript function to remove the trailing slash from the path.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 18, 2015
01:09 PM
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.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 19, 2015
01:29 AM
This code here should get you through.... and I assume you have a Basic MSI project type.
[CODE]export prototype set_prop(HWND);
function set_prop(hMSI)
STRING tmpINSTALLDIR;
STRING svInstalldir[256];
NUMBER nBuffer;
begin
tmpINSTALLDIR = INSTALLDIR;
nBuffer = 256;
StrRemoveLastSlash(tmpINSTALLDIR);
MsiSetProperty(hMSI,"DOUBLE_INSTALLDIR",tmpINSTALLDIR);
end;[/CODE]
[CODE]export prototype set_prop(HWND);
function set_prop(hMSI)
STRING tmpINSTALLDIR;
STRING svInstalldir[256];
NUMBER nBuffer;
begin
tmpINSTALLDIR = INSTALLDIR;
nBuffer = 256;
StrRemoveLastSlash(tmpINSTALLDIR);
MsiSetProperty(hMSI,"DOUBLE_INSTALLDIR",tmpINSTALLDIR);
end;[/CODE]
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 19, 2015
07:13 AM
Thanks.
I will try it.
Do I need another new property though to store the final value in?
Or do I change this: Session.Property("DOUBLE_INSTALLDIR") = Replace( Session.Property("INSTALLDIRNOTRAIL"), "\", "\\" )
To this: Session.Property("DOUBLE_INSTALLDIR") = Replace( Session.Property("DOUBLE_INSTALLDIR"), "\", "\\" )
I will try it.
Do I need another new property though to store the final value in?
Or do I change this: Session.Property("DOUBLE_INSTALLDIR") = Replace( Session.Property("INSTALLDIRNOTRAIL"), "\", "\\" )
To this: Session.Property("DOUBLE_INSTALLDIR") = Replace( Session.Property("DOUBLE_INSTALLDIR"), "\", "\\" )
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 19, 2015
07:26 AM
Nope not necessary ... you can still have one property DOUBLE_INSTALLDIR and perform all the actions (remove the trailing slash, remove double slash) on it.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 19, 2015
07:34 AM
Well, that didnt work either.
I keep getting the attached error when running the .MSI.
It is referencing my custom action which has this code: Session.Property("DOUBLE_INSTALLDIR") = Replace( Session.Property("DOUBLE_INSTALLDIR"), "\", "\\" )
But that did work when the replace statement was replacing just INSTALLDIR.
LOL...
I keep getting the attached error when running the .MSI.
It is referencing my custom action which has this code: Session.Property("DOUBLE_INSTALLDIR") = Replace( Session.Property("DOUBLE_INSTALLDIR"), "\", "\\" )
But that did work when the replace statement was replacing just INSTALLDIR.
LOL...
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 19, 2015
07:48 AM
Appears to be a problem with the custom action sequence.
1: Run the InstallScript Custom action and result is DOUBLE_INSTALLDIR property is loaded with INSTALLDIR value without trailing slash.
2: Run your custom action which does "\\" to "\" on DOUBLE_INSTALLDIR property
1: Run the InstallScript Custom action and result is DOUBLE_INSTALLDIR property is loaded with INSTALLDIR value without trailing slash.
2: Run your custom action which does "\\" to "\" on DOUBLE_INSTALLDIR property
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 19, 2015
07:50 AM
rrinblue22 wrote:
Appears to be a problem with the custom action sequence.
1: Run the InstallScript Custom action and result is DOUBLE_INSTALLDIR property is loaded with INSTALLDIR value without trailing slash.
2: Run your custom action which does "\\" to "\" on DOUBLE_INSTALLDIR property
Yea, that is what I am doing:
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 19, 2015
07:53 AM
you can also just write one single VBScript which performs both task of removing the trailing slash and "\\" to "\".
just a suggestion to un-complicate things 🙂
just a suggestion to un-complicate things 🙂
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 19, 2015
07:59 AM
Well..
Now I am closer than ever before.
Now it is kind of working, however, my config file ends up with two rows:
Thank you for all the help though. I am now almost there.
I guess in the XML Editor I can add a remove line to remove the bad one? Not sure why I should have to do that though.
Now I am closer than ever before.
Now it is kind of working, however, my config file ends up with two rows:
Thank you for all the help though. I am now almost there.
I guess in the XML Editor I can add a remove line to remove the bad one? Not sure why I should have to do that though.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 19, 2015
08:12 AM
I have just sent an email to your RatBoyGL account here.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 19, 2015
08:18 AM
Replied.
ROFL...
ROFL...