cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
mrohit
Level 4

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
Labels (1)
0 Kudos
(3) Replies
cbragg
Level 7

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"
0 Kudos
mrohit
Level 4

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
0 Kudos
cbragg
Level 7

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.
0 Kudos