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: Appending text to an already existing file
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
‎Sep 17, 2009
06:16 AM
Appending text to an already existing file
Hi,
I would like to know if there is any option in InstallShield 2010 or InstallShield 12 Professional edition to directly "Append" text to already existing file?
For ex: I want to append to hosts file a server name or IP address picked up from end-user during installation
Using InstallShield how can this be achieved ?
If not any other ways of achieving the same?
Any input/suggestions is appreciated.
Thanks
Rohit
I would like to know if there is any option in InstallShield 2010 or InstallShield 12 Professional edition to directly "Append" text to already existing file?
For ex: I want to append to hosts file
Using InstallShield how can this be achieved ?
If not any other ways of achieving the same?
Any input/suggestions is appreciated.
Thanks
Rohit
(3) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 17, 2009
07:26 AM
There's no out of the box funtionality but you can easily write your own custom action to do it. You can use this vbscript:
Const ForAppending = 8
Dim objFSO, objFile
Dim args: args = Split(Session.Property("CustomActionData"),",")
Set objfso = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(args(0), ForAppending, True)
objFile.WriteLine(args(1))
objFile.Close
You run this script in deferred mode because any changes made to a machine should always be made in deferred mode. You then create a 'set property' custom action to run immediately rather than deferred, call it what you like but the property name that you are setting is the name of the custom action that runs the script. In the value you need to put the filename (use the filekey from the file table so it's path changes correctly when the user installs somewhere else) followed by a comma followed by the text you want added
example value could be:
[#myfile.exe],"192.168.1.123 MyServer"
Const ForAppending = 8
Dim objFSO, objFile
Dim args: args = Split(Session.Property("CustomActionData"),",")
Set objfso = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(args(0), ForAppending, True)
objFile.WriteLine(args(1))
objFile.Close
You run this script in deferred mode because any changes made to a machine should always be made in deferred mode. You then create a 'set property' custom action to run immediately rather than deferred, call it what you like but the property name that you are setting is the name of the custom action that runs the script. In the value you need to put the filename (use the filekey from the file table so it's path changes correctly when the user installs somewhere else) followed by a comma followed by the text you want added
example value could be:
[#myfile.exe],"192.168.1.123 MyServer"
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 18, 2009
08:45 AM
Thanks CBragg,
i could make use of your steps and make an entry to a file with minor changes.
I was also trying to setup a Dialog and try to insert different controls in it. for ex. i wanted to create a dialog that takes two inputs: Server Name & Server IP.
I tried with all options of dialogs [Blank/Exterior/Interior] but couldn't get the controls to meet my requirement.
Can you/anybody provide some more information on the same?
Thanks Again
Rohit
i could make use of your steps and make an entry to a file with minor changes.
I was also trying to setup a Dialog and try to insert different controls in it. for ex. i wanted to create a dialog that takes two inputs: Server Name & Server IP.
I tried with all options of dialogs [Blank/Exterior/Interior] but couldn't get the controls to meet my requirement.
Can you/anybody provide some more information on the same?
Thanks Again
Rohit
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 18, 2009
09:22 AM
Glad the advice worked for you. You need to create an interior dialog so that it looks like the other dialogs. However you need to pull down text boxes from the control toolbox onto your form and assign them properties. To be honest, to go into dialog designing here would take up too much space and would need to refer you to the installshield help.