Dim strAllLines,strTxtFile,strMatch,objFSO,objFile,strNewText
Const ForReading = 1
Const ForWriting = 2
Set objNetwork = CreateObject("Wscript.Network")
strUser = objNetwork.UserName
strTxtFile = "C:\Documents and Settings\" & strUser & "\Rest of the Path"
strMatch = "TEXT TO BE MODIFIED"
strNewText = "TEXT TO REPLACE ORIGINAL"
'Reads the TXT file
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strTxtFile, ForReading)
strAllLines = objFile.ReadAll
objFile.Close
strNewText = Replace(strAllLines,strMatch,strNewText)
Set objFile = objFSO.OpenTextFile(strTxtFile, ForWriting)
objFile.WriteLine(strNewText)
objFile.Close
|