PDA

View Full Version : Adding a line to an existing file



Wenche
05-02-2002, 06:05 AM
Hello!

I have a problem with an installation that adds a line to the existing "hosts." file. I make a package of the installation, and everything looks OK, but the line that should have been added to "hosts." is not there.

In my .inc file the following line appears, and I think this is the line that should be responsible for adding the line in my project:

ModifyOemEx('%SystemFolder%\drivers\etc\hosts.','','','0',moInsertAlphabetical+moOverwriteExisting+moTcpConfigMode)
193.160.184.20 swift-p1

Does anybody know why the line are not been added, or another way for me to add the line in my project.


Regards,
Wenche

TsungH
06-13-2002, 07:42 PM
I don't know exactly why it didn't get created during import process. However, you can add a custom action in VBScript (or any language you are comfortable with) to write a line to "hosts" file. Remember to add another custom action to remove this change upon uninstallation, if desired.

iburnell
10-09-2002, 04:18 AM
The VB code here is great. I have used it to append entries to hosts and services files. However, what is the procedure to UNINSTALL the changes made. I know there'll need to be a custom action made but doesn't there need to be some seaparate VB to read each line of the file and delete the entries or is the Installation intelligent enough to do this automatically (unlikely!)

TsungH
10-10-2002, 07:24 PM
In this scenario, the installation will not be smart enough to undo what the VBScript custom action (CA) did. We will need to remove the addition using a CA during uninstallation.

iburnell
10-18-2002, 04:53 AM
Yes - but how!!!!

I'm not a VB programmer. Perhaps you could show how you would remove the line in your example writetohosts file

TsungH
10-21-2002, 03:36 PM
Here is the VBScript that removes the line added. Personally, I prefer using a DLL over a VBScript in this case.