Path: news.easynews.com!newsfeed1.easynews.com!easynews.com!easynews!cyclone1.gnilink.net!canoe.uoregon.edu!logbridge.uoregon.edu!newsfeed.stanford.edu!postnews1.google.com!not-for-mail
From: rs_arwar@hotmail.com (Rauf Sarwar)
Newsgroups: comp.databases.oracle.server
Subject: Re: Listing Oracle Databases on Windows
Date: 2 Mar 2003 23:06:52 -0800
Organization: http://groups.google.com/
Lines: 52
Message-ID: <92eeeff0.0303022306.23a825e3@posting.google.com>
References: <yVj8a.310694$HN5.1353446@rwcrnsc51.ops.asp.att.net>
NNTP-Posting-Host: 67.30.221.122
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1046675212 19106 127.0.0.1 (3 Mar 2003 07:06:52 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: 3 Mar 2003 07:06:52 GMT
Xref: newsfeed1.easynews.com comp.databases.oracle.server:178216
X-Received-Date: Mon, 03 Mar 2003 00:06:45 MST (news.easynews.com)

<dan1999a@attbi.com> wrote in message news:<yVj8a.310694$HN5.1353446@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
