Set FSO = CreateObject("Scripting.FileSystemObject")
' Open file and obtain file handle Const ForReading = 1, ForWriting = 2, ForAppending = 8 ' Constant Value Description ' TriStateUseDefault -2 Opens the file using the system default ' TriStateTrue -1 Opens the file as Unicode ' TriStateFalse 0 Opens the file as ASCII
Not a problem at all, i know all of us here are more then glad to be of help. I picked up this script before but never tried it as I had other deplicate entries. In your case, I see there would be a need for it.
This script searches through the pre-determined file for a text and copies all other lines not matching that text to the temp file. At the end of the script, it deletes the original and renames the new.
good luck 🙂
Set FSO = CreateObject("Scripting.FileSystemObject") CfgPath = Session.Property("SystemFolder") & "drivers\etc\hosts" CfgTmp = "C:\Winnt\System32\Drivers\Etc\hosts.tmp" Set Fin = FSO.OpenTextFile(CfgPath, 1, False, 0) Set Fout = FSO.CreateTextFile(CfgTmp, false, false) Do While Fin.AtEndOfStream <> True szLine = Fin.ReadLine ' "NTSDTELCO1007A NTSDTELCO1007A #NTSDTELCO1007A" is the line added if (szLine <> "NTSDTELCO1007A NTSDTELCO1007A #NTSDTELCO1007A") then Fout.WriteLine szLine end if Loop Fin.Close Fout.Close
Thanks for the reply. This may be a stupid question but how do I trigger the "remove" script with a custom action. It only needs to run when the software is being uninstalled. It isnt clear to me through either the custom action wizard or creating it manually as to how to do this.