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

Adding a line to an existing file

CChong
By Level 11 Flexeran
Level 11 Flexeran
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
(5) Replies
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.
CChong
By Level 11 Flexeran
Level 11 Flexeran
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!)
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.
CChong
By Level 11 Flexeran
Level 11 Flexeran
Yes - but how!!!!

I'm not a VB programmer. Perhaps you could show how you would remove the line in your example writetohosts file
Here is the VBScript that removes the line added. Personally, I prefer using a DLL over a VBScript in this case.