Installing Inno to add an entry to the hosts file under windows 7

Can someone help me with an example installation of an inno script showing how to add an entry to a Windows 7 hosts file?

thanks

+4
source share
2 answers

lmhost supports #include statements, so you can include your own hosts file as follows:

//call after inno setup step change procedure UpdateLMhosts(CurStep: TSetupStep); var contents: TStringList; filename, statement: String; i: Integer; begin if(CurStep=ssDone) then begin filename := ExpandConstant('{sys}\drivers\etc\lmhosts'); Log('Reading ' + filename); contents := TStringList.Create(); if(FileExists(filename)) then begin contents.LoadFromFile(filename); end; //copy my lmhosts to the system lmhosts statement := ExpandConstant('#INCLUDE {commonappdata}\MyBrand\MyApp\lmhosts'); if(contents.IndexOf(statement) < 0) then begin Log('Adding' + statement); contents.Append(statement); contents.SaveToFile(filename); end; end; end; 
+3
source

This seems like a task that goes beyond what Inno Setup provides.

See the following knowledge base article for suggestions: http://www.jrsoftware.org/iskb.php?custom

+2
source

All Articles