I need a script to remove this string "custombuttons-button353," from a file located here "C:\localstore.rdf.
I would appreciate any help.Note: I hope no one becomes upset that I am posting the same question in the VB forum.
I posted this question differently on another forum and received a reply which worked pefectly
My question was answered by "PHV" on another forum here:http://www.tek-tips....cfm?qid=1672632
The question I asked there was a bit different than what I asked here but the answer is applicable.My post on the other forum:
--------------------------------------
I have the "replace.vbs" file saved to C:\Windows.I use it to find and replace strings in text files.
Command line Syntax:
replace.vbs OLDSTRING NEWSTRING C:\file.txtHow can I modify the replace.vbs script to delete the string rather than replace it with another string?
replace.vbs
----------------------------------
Dim FileName, Find, ReplaceWith, FileContents, dFileContentsFind = WScript.Arguments(0)
ReplaceWith = WScript.Arguments(1)
FileName = WScript.Arguments(2)
FileContents = GetFile(FileName)
dFileContents = replace(FileContents, Find, ReplaceWith, 1, -1, 1)
if dFileContents <> FileContents ThenWriteFile FileName, dFileContents
End If
function GetFile(FileName)If FileName<>"" Then
Dim FS, FileStream
Set FS = CreateObject("Scripting.FileSystemObject")
on error resume Next
Set FileStream = FS.OpenTextFile(FileName)
GetFile = FileStream.ReadAll
End If
End Function
function WriteFile(FileName, Contents)Dim OutStream, FS
on error resume NextSet FS = CreateObject("Scripting.FileSystemObject")
Set OutStream = FS.OpenTextFile(FileName, 2, True)
OutStream.Write Contents
End Function
-------------------------The reply which worked perfectly:
--------------------
New PostPHV (MIS)22 Jan 12 9:10
What happens if you use this command line ?
[b]replace.vbs OLDSTRING "" C:\file.txt[/b]----------------------------------
Typo should be "perfectly"
This is the correct link to the post:*http://www.tek-tips.com/viewthread.cfm?qid=1672632*
