Solved

Inno setup & windows 7 hosts file entry

Posted on 2010-08-13
2
1,973 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
Comment Utility
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
Comment Utility
Thanks
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now