How do I replace a string in a text file with another string, including quotes?
For example, I have an xml sting that reads:
<test name="My name is Rick" value="False" />
and I want replace to replace the value="False" to value="True" so that it ends up like this:
<test name="My name is Rick" value="True" /> and it must include the quotes.
This is part of my vbs code
Dim FileName, FileName2, Find, ReplaceWith, FileContents, dFileContents
Find = WScript.Arguments(0)
ReplaceWith = WScript.Arguments(1)
FileName = WScript.Arguments(2)
FileName2 = WScript.Arguments(3)
Wscript.Echo ("Find: " & Find & vbCrLf & "Replacewith: " & Replacewith & vbCrLf & "FileName: " & FileName & vbCrLf & "FileName2: " + FileName2)
FileContents = GetFile(FileName)
dFileContents = Replace(" & FileContents & ", Find, " & ReplaceWith & ", 1, -1, 1)
if dFileContents <> FileContents Then
WriteFile FileName2, dFileContents
Else
Wscript.Echo "Searched string Not In the source file"
End If