Solved

Need a VB script file to change 1 line in an .INF file

Posted on 2013-05-22
4
436 Views
Last Modified: 2013-05-24
I'm moving a license manager from one server to another. The software points to the license manager via a line in a .INF file. This change affects most computers on our campus, including computer labs and faculty/staff computers.

The single line in the .INF file involved is a line that states "DaemonHost = /servername/"

I've been "requested" by the help Desk to find a VB script that will change the line from "DaemonHost = /oldservername/" to "DaemonHost = /newservername/"

Since there will be both XP and Win 7 computers involved, it would be great if both OS's were covered in the same script, if possible.

Thanks in advance for any help.
0
Comment
Question by:wheelgunr
  • 3
4 Comments
 
LVL 25

Expert Comment

by:SStory
ID: 39187482
0
 

Author Comment

by:wheelgunr
ID: 39187771
I've looked at those, and tried my variables, but I can't get it to work. The .INF file is locates under program files\IBM\SPSS\Statistics\20\spssprod.inf

There's a line in there that gives DaemonHost=//servername//. I need to change that server name entry.

Suggestions?
0
 
LVL 25

Expert Comment

by:SStory
ID: 39188907
Well, do you have access to the file or is there a file access issue?

I suggest you move the file to a location that you definitely have access to and run the script against it.

I modified the script a bit to use a single var for filename. Change
strInFilePath to the location of the file to be edited. (again try placing it in a location you definitely have rights to, like My Documents or something to see if it is a permissions thing.

Const ForReading = 1
Const ForWriting = 2

strInFilePath = "C:\Scripts\Text.txt"
strOutFilePath = strInFilePath

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strInFilePath, ForReading)

strText = objFile.ReadAll
objFile.Close

'the following two lines should be on a single line
strNewText = Replace(strText, "DaemonHost = /oldservername/", "DaemonHost = /newservername/")

Set objFile = objFSO.OpenTextFile(strOutfilePath, ForWriting)
objFile.WriteLine strNewText
objFile.Close
0
 
LVL 25

Accepted Solution

by:
SStory earned 500 total points
ID: 39188913
If you are allowed to use a utility, FART.EXE works great.
http://sourceforge.net/projects/fart-it/  (Find and Replace Text)
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
A short article about problems I had with the new location API and permissions in Marshmallow
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

762 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

18 Experts available now in Live!

Get 1:1 Help Now