?
Solved

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

Posted on 2013-05-22
4
Medium Priority
?
491 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
[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
  • 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 1000 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 Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A short article about problems I had with the new location API and permissions in Marshmallow
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
Introduction to Processes
Starting up a Project
Suggested Courses

765 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