?
Solved

Inno setup & windows 7 hosts file entry

Posted on 2010-08-13
2
Medium Priority
?
2,190 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:
Meir Rivkin earned 2000 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

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

Make the most of your online learning experience.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
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 …
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…

809 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