Solved

Inno setup & windows 7 hosts file entry

Posted on 2010-08-13
2
2,000 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

861 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

30 Experts available now in Live!

Get 1:1 Help Now