effectively you are just writting a text file yeah? it might have a different extension (.udl) but it is just plan text.
So why can't you read in the file (similar to what you are doing). Find the properties you want to change. Replace them and write them back out.
Effectively your file is a collection of value pairs eg X=123;Y=345;Z=234
So I would do something like this.... read in each line and add for each line split it on the semi colon to get your value pairs, then split each value pair on the equals sign to get a name and a value. If the name is one of the ones you want to replace change the value. Then rewrite the line based on the new value pairs....
Code:
newProvider="sqloledb"
Dim fso, f1, ts, s
Const ForReading = 1
Set fso = CreateObject("Scripting.FileSystemObject")
Set orginalTS = fso.OpenTextFile("c:\orgfile.udl", ForReading)
Set newTS = fso.CreateTextFile("c:\newfile.udl", true)
do while orginalLine<>""
newLine = ""
valuePairs = split(orginalLine,";")
for i = 0 to valuePairs.UBound ' might need ubound-1
pair = split(valuePairs(i),"=")
if pair.Ubound = 2 then ' we have a valid value pair to check
name = UCase(pair(0))
namevalue = pair(1)
if name = PROVIDER" then
pair(1) = newProvider
end if
valuePairs(i) = pair(0) & "=" & pair(1)
end if
newLine = newLine & valuePairs(i)
next
newTS.WriteLine(newLine)
orginalLine = orginalTS .ReadLine
loop
orginalTS .Close
newTS .Close
Set fso = nothing
Set orginalTS = nothing
Set newTS = nothing
That should be pretty close I think.... I haven't tested it at all. There are a couple of comments there that you might want to check on. The area I have bolded is where you would add the other names of value pairs to replace. You could use a case statement here if you wanted.