tourcd
IS-IT--Management
- Dec 5, 2005
- 37
Hi,
I have a text file called "Params.txt", it contains the following...
start
Servername =
IP Address =
end
I'm trying to append a server name and IP address on to the corresponding lines. I've got the following code that will happily append the server name but I can't figure out how I can append the IP address within in a neat way. I can open the file, write the line, close the file and repeat this for each parameter. I wanted a smarter way of doing it, can someone give me a pointer?
Many thanks
Here's an extract of my code...
Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Params.txt", ForReading)
strText = objFile.ReadAll
objFile.Close
strNewServername = Replace(strText, "Servername = ", "Servername = " & ServerName.Value)
Set objFile = objFSO.OpenTextFile("C:\Params.txt", ForWriting)
objFile.WriteLine strNewServername
objFile.Close
I have a text file called "Params.txt", it contains the following...
start
Servername =
IP Address =
end
I'm trying to append a server name and IP address on to the corresponding lines. I've got the following code that will happily append the server name but I can't figure out how I can append the IP address within in a neat way. I can open the file, write the line, close the file and repeat this for each parameter. I wanted a smarter way of doing it, can someone give me a pointer?
Many thanks
Here's an extract of my code...
Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Params.txt", ForReading)
strText = objFile.ReadAll
objFile.Close
strNewServername = Replace(strText, "Servername = ", "Servername = " & ServerName.Value)
Set objFile = objFSO.OpenTextFile("C:\Params.txt", ForWriting)
objFile.WriteLine strNewServername
objFile.Close