Wednesday, September 3, 2014

Deleting 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 delete accordingly.


On Error Resume Next
Const ForReading = 1
Const ForWriting = 2

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

StrCurrPath = Replace(Wscript.ScriptFullName,Wscript.ScriptName,"")
ORAFilePath   = Wshshell.ExpandEnvironmentStrings("%systemdrive%") & "\oracle\product\11.2.0.2.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
StrData = Replace(StrReadORAFile,StrReadTmpORAFile,"")
Set objORAfile = objFSO.OpenTextFile(ORAFilePath, ForWriting)
objORAfile.Write StrData
objORAfile.close

End If

1 comment: