Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

920 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

17 Experts available now in Live!

Get 1:1 Help Now