?
Solved

Inno setup & windows 7 hosts file entry

Posted on 2010-08-13
2
Medium Priority
?
2,137 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 42

Accepted Solution

by:
sedgwick 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

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

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.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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 …

764 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