vbs help..

Speak your mind

vbs help..

Postby epitaph on Sun Jun 18, 2006 8:51 pm

i dont know anything about vbs and im not sure if it can be done but can this be changed to include * as a wild card? because as of right now it wont recognize it as a wild card and i really need it too :( . thanks.

Dim FileName, Find, ReplaceWith, FileContents, dFileContents
Find = 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 Then
WriteFile FileName, dFileContents
Else
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 Next
Set FS = CreateObject("Scripting.FileSystemObject")
Set OutStream = FS.OpenTextFile(FileName, 2, True)
OutStream.Write Contents
End Function
epitaph
 
Posts: 58
Joined: Wed Apr 19, 2006 8:28 am