Solved

Inno setup & windows 7 hosts file entry

Posted on 2010-08-13
2
2,040 Views
Last Modified: 2013-11-14
Can anyone help me with a inno setup sample script showing how to add an entry to windows 7 hosts file?
0
Comment
Question by:VPDD
2 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 33440684
follow this steps:

1. open notepad and add the following code:

Set objFSO = CreateObject("Scripting.FileSystemObject")
set objFile = objFSO.OpenTextFile("C:\Windows\System32\drivers\etc\hosts", 8)
objFile.WriteLine "<IP SERVER_NAME>"
objFile.Close

2. replace <IP SERVER_NAME> with what ever entry you wish to add.
if u have more than one entry to add, duplicate this line for each ip + server name:
objFile.WriteLine "<IP1 SERVER_NAME1>"
objFile.WriteLine "<IP2 SERVER_NAME2>"
and so on.

3. save the file as update_hosts.vbs.

4. in your inno setup script, under [Files] section, add the following line:
Source: "update_hosts.vbs"; DestDir: "{app}"

the source should contain the full path of the vbs file.

5. add section [Run], and add the following line:
Filename: "cscript"; Parameters: "{app}\update_hosts.vbs"

and that's it.
the vbs file will be run by the installer and should update the hosts file.

make sure the hosts file is under: C:\Windows\System32\drivers\etc\


0
 

Author Comment

by:VPDD
ID: 33444902
Thanks
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PHP installation issues 11 78
Changing Antivirus for Corporatre Network 11 69
backup program with robocopy 6 46
Mac OS 10.7.5 upgrade 3 44
A short article about problems I had with the new location API and permissions in Marshmallow
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question