Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Listing Oracle Databases on Windows
<dan1999a_at_attbi.com> wrote in message news:<yVj8a.310694$HN5.1353446_at_rwcrnsc51.ops.asp.att.net>...
> Hi Oracle DBAs,
>
> In UNIX, to get a list of Oracle databases on a server, I do this in my
> script:
> grep ^[A-Z,a-z] /etc/oratab
>
> Is there a way that I can script out getting a list of Oracle databases and
> its Oracle Home in a Windows environment? I'm trying to write a script that
> will run for each Oracle database on a server.
>
> Also, is there a way of doing this using PERL?
>
> Thanks in advance.
Each installed database on a Windows NT based systems has a service
entry in the registry. Service name is like "OracleService<SID>". To
query regisrty, there is an NT resource kit utility called REG.EXE
which you can download for free from
http://www.dynawell.com/support/Reskit/winnt.asp. Look for "Registry
command line utility". Once you have that, you can use following
sequence of commands from a batch script,
I have two instances on my laptop TEST920 and TEST817
@ECHO OFF
SET REGSTR=HKLM\SYSTEM\CURRENTCONTROLSET\SERVICES
FOR /F "delims=[,]" %%A IN ('REG QUERY %REGSTR%^|find /i
"OracleService"') DO (
REG QUERY %REGSTR%\%%A\ImagePath) >> OUT.TXT FOR /F "tokens=1-4" %%A IN (OUT.TXT) DO ECHO %%D
Will display
TEST817
TEST920
If I use the last command as,
FOR /F "tokens=1-4" %%A IN (OUT.TXT) DO ECHO %%C
Will display Oracle.exe executable with complete path for both databases like,
C:\Oracle\Ora817\bin\Oracle.exe
C:\Oracle\Ora920\bin\Oracle.exe
You can easily parse out these to extract Oracle home.
Regards
/Rauf Sarwar
Received on Mon Mar 03 2003 - 01:06:52 CST