Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2013-05-22
4
Medium Priority
?
498 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Introduction to Processes
Suggested Courses

604 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