Thursday, 2 August 2012
Add Lines to File - VBSCript
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("C:\oracle\ora81\network\admin\tnsnames.ora", ForReading)
Do Until objTextFile.AtEndOfStream
strLine = objTextFile.ReadLine
intFailure = InStr(strLine, "LINE 1")
intFailure2 = InStr(strLine, "LINE 2")
intfailure3 = InStr(strLine, "LINE 3")
intfailure4 = InStr(strLine, "LINE 4")
intfailure5 = InStr(strLine, "LINE 5")
intfailure6 = InStr(strLine, "LINE 6")
intfailure7 = InStr(strLine, "LINE 7")
If intFailure > 0 or intFailure2 > 0 or intFailure3 > 0 or intFailure4 > 0 or intFailure5 > 0 or intFailure6 > 0 intFailure7 > 0 Then
strNewText = strNewText & strLine & vbCrLf
Else
strOtherNewText = strOtherNewText & strLine & vbCrLf
End If
Loop
objTextFile.Close
Set objTextFile = objFSO.OpenTextFile("C:\oracle\ora81\network\admin\tnsnames.ora", ForWriting, True)
objTextFile.Write(strOtherNewText)
objTextFile.Close
'****************************************************************************************************************
dim filesys, filetxt
Set filesys = CreateObject("Scripting.FileSystemObject")
Set filetxt = filesys.OpenTextFile("C:\oracle\ora81\network\admin\tnsnames.ora", ForAppending, True)
filetxt.WriteLine("LINE 1")
filetxt.WriteLine("LINE 2")
filetxt.WriteLine("LINE 3")
filetxt.WriteLine("LINE 4")
filetxt.WriteLine("LINE 5")
filetxt.WriteLine("LINE 6")
filetxt.WriteLine("LINE 7")
filetxt.Close
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment