Solved

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

Posted on 2013-05-22
4
477 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 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 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

Suggested Solutions

Title # Comments Views Activity
C qsort compare function issue 6 44
learn programming 8 72
Getting Variable not defined error in Python 1 45
C# Windows Form Navigation - Total Beginner 9 48
A short article about a problem I had getting the GPS LocationListener working.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
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 …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

726 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