Link to home
Start Free TrialLog in
Avatar of BEI_INC
BEI_INC

asked on

Search a network folder for a file in VBS

I am looking for some help in a script.  We have folder on our server for our users home directory.  
There is a file in each one called config.xml.  I need to mass edit some lines.  I found this and it works but I can't figure out how to search for every instance of the file in all sub folders in the share.
Const ForReading = 1
Const ForWriting = 2

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\config.xml", ForReading)

strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, "<PromptOnShutDown>1</PromptOnShutDown>", "<PromptOnShutDown>0</PromptOnShutDown>")

Set objFile = objFSO.OpenTextFile("C:\config.xml", ForWriting)
objFile.WriteLine strNewText
objFile.Close

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\config.xml", ForReading)

strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, "<PurgeOnShutDown>1</PurgeOnShutDown>", "<PurgeOnShutDown>0</PurgeOnShutDown>")

Set objFile = objFSO.OpenTextFile("C:\config.xml", ForWriting)
objFile.WriteLine strNewText
objFile.Close

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\config.xml", ForReading)

strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, "<CompactOnShutDown>1</CompactOnShutDown>", "<CompactOnShutDown>0</CompactOnShutDown>")

Set objFile = objFSO.OpenTextFile("C:\config.xml", ForWriting)
objFile.WriteLine strNewText
objFile.Close

Open in new window


This will only search a specific location.  I would need it to search the folder, find the file, edit these line, and then move to the next one and repeat.

Thanks for any help!
ASKER CERTIFIED SOLUTION
Avatar of Tasmant
Tasmant
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BEI_INC
BEI_INC

ASKER

Thanks!