Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Issuing Oracle administrative commands from restricted user account

Re: Issuing Oracle administrative commands from restricted user account

From: FC <flavio_at_tin.it>
Date: Fri, 14 Feb 2003 12:37:52 GMT
Message-ID: <Aq53a.241246$AA2.9265959@news2.tin.it>

"Rauf Sarwar" <rs_arwar_at_hotmail.com> wrote in message news:92eeeff0.0302131946.53cfc8ef_at_posting.google.com...
> "FC" <flavio_at_tin.it> wrote in message news:<GNI2a.175157> Yeah, I know
that works, my problem is slightly different.
> > If you put commands like LSNCRTL in a batch command file (.bat, .cmd),
even
> > if you "runas /user:Administrator" the script, they don't work,
presumably
> > because they do not inherit administrator rights from the calling
> > environment or some other unknown reason.
> > If you run them one at a time with RUNAS they work, but inside a batch
> > program they don't.
> > The most acceptable solution I found so far is to open a command prompt
with
> > Administrator rights, then you can run any command you like from there
and
> > you have to type the Administrator password only once.
> > However, in this fashion, you cannot just point and click, you must
supply
> > the batch program name every time.
> > I just wanted to create some small scripts that prompted the user for
the
> > administrator password, no matter what your current account is and put
them
> > on the desktop or some other folder, ready to be launched.
> > I have an Oracle multi-home environment and having different scripts to
> > start up or shutdown a certain db instance and or listener and or
related
> > service is very handy.
> > Not a big deal probably, but still I can't find a way around it.
>
>
> How about something like this then,
>
> Create a script called e.g. run.bat with all your commands
> lsnrctl start
> .......
> .......
>
> Create another script e.g. call.bat with runas command
> runas /user:<DOMAIN\administrator "cmd /c call <PATH>\run.bat"
>
> Double click on call.bat and you will be prompted for password. After
> that all commands in run.bat will run as administrator.
>
> Hope this helps
> /Rauf Sarwar

Got it!
Initially I tried something like what you say, but unsuccessfully, here it is what I did:
my original script is called admin.bat:

  runas /user:administrator "cmd /C %1"

then I have another script called orastart.bat:

  lsnrctl start listener
  oradim -startup -sid DEVDB

So I was executing the following:

  admin orastart.bat

After prompting the password, the script ran for a second or so, but it didn't succeed in starting up anything.
Since admin.bat and orastart.bat were in the same directory and I was executing them from that directory, I excluded problems with the path, but that's a wrong assumption because I realized that when you invoke the shell via cmd, the current directory becomes %WINDIR%\system32, so I have to specify the full path to the script being called. As I am very lazy I came up with the following modified program that seems to work just fine, provided you place the admin.bat script in any directory along the PATH or together with the other scripts.

admin.bat:

  runas /user:administrator "cmd /C call \"%~f1\""

Full path expansion of the batch program being called is carried out automatically by the OS and passed as a parameter to the shell command, moreover it supports directory names with blanks or other fancy characters.

Thanks and bye,
Flavio Received on Fri Feb 14 2003 - 06:37:52 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US