Wednesday, September 3, 2014

Appending entries in ora file using VBscript

Create one temp.ora file in the location of Vbscript and add the entries manually in temp.ora file.

When executing vb script it will compare the temp.ora file with test.ora in this  location(\oracle\product\11.0.0.0.0\network\admin\) and it will append accordingly.

On Error Resume Next
Const ForReading = 1
Const ForWriting = 2
const ForAppending = 8

Set Wshshell = CreateObject("Wscript.Shell")
Set objFSO   = CreateObject("Scripting.FileSystemObject")

StrCurrPath = Replace(Wscript.ScriptFullName,Wscript.ScriptName,"")
ORAFilePath   = Wshshell.ExpandEnvironmentStrings("%systemdrive%") & "\oracle\product\11.0.0.0.0\network\admin\"
ORAFilePath     = ORAFilePath & "Test.ora"
TmpORAFilePath = StrCurrPath & "Temp.ora"

Set objORAfile = objFSO.OpenTextFile(ORAFilePath, ForReading)
 StrReadORAFile= objORAfile.ReadAll
objORAFile.Close


Set objTmpORAfile = objFSO.OpenTextFile(TmpORAFilePath, ForReading)
 StrReadTmpORAFile= objTmpORAfile.ReadAll
objTmpORAfile.Close

If Instr(StrReadORAFile,StrReadTmpORAFile) = 0 then
Set objORAfile = objFSO.OpenTextFile(ORAFilePath, ForAppending)
 objORAfile.Writeline StrReadTmpORAFile
objORAFile.Close

End if

No comments:

Post a Comment