bt707
asked on
vbs add line if it does not exist
I have a ini file that I need to replace a few lines in, with the code below I can replace the two lines I need and that works fine.
The problem I have is that some of the files does not contain a line of DefaultMailto, how can I check to see if the file contains the line of DefaultMailto and if not then add DefaultMailto=0. Also the file sometimes does have a line of WarnDefaultMailto= so also have to keep this line from being found when looking for DefautlMailto=.
Thanks,
The problem I have is that some of the files does not contain a line of DefaultMailto, how can I check to see if the file contains the line of DefaultMailto and if not then add DefaultMailto=0. Also the file sometimes does have a line of WarnDefaultMailto= so also have to keep this line from being found when looking for DefautlMailto=.
Thanks,
Const ForReadingPRF = 1
Const ForWritingPRF = 2
Set objFSOPRF = CreateObject("Scripting.FileSystemObject")
Set objFilePRF = objFSOPRF.OpenTextFile(EiniPath, ForReadingPRF)
newPOPaccount = "POPAccount=" & MigrateAlias & "@NO_PoP_Mail"
strTextPRF = objFilePRF.ReadAll
objFilePRF.Close
strNewTextPRF = Replace(strTextPRF, "DefaultMailto=1", "DefaultMailto=0")
strNewTextLOS = Replace(strNewTextPRF, "POPAccount=NO_PoP_Mail", newPOPaccount)
Set objFilePRF = objFSOPRF.OpenTextFile(EiniPath, ForWritingPRF)
objFilePRF.WriteLine strNewTextLOS
objFilePRF.Close
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks,