**DONOTDELETE**
(Lurker)
2001-10-15 01:44 PM
Using admin rights in script

Hi

I need to remove admin group rights from local PCs, so therefore need to run the command as local admin. I have worked out how to remove the rights, but cannot do it as a normal user - eg
SHELL 'CMD /C net localgroup administrators "DOMAIN\Local ADMIN GROUP" /delete'
Does anyone know how to do this as admin and then switch back to normal user after that has been done ?

Thanks

**DONOTDELETE**
(Lurker)
2001-10-15 02:09 PM
Re: Using admin rights in script

Use SU.exe
That might do the trick but read the documentation before you try anything out.

//robban

MCA
(KiX Supporter)
2001-10-16 05:59 AM
Re: Using admin rights in script

Dear,

You can find more information about the SU utility on Bryce's site http://kix.isorg.net .
Relevant links:
http://kix.isorg.net/other_scripts/su/
and
http://kix.isorg.net/other_scripts/su/KiXtart&SU.rtf (= documentation)
Search also on this board for SU and you will find a lot of additional
information.
Greetings.


btw: we advice you to use shell "%comspec% /c ..." instead of shell "cmd /c ..."

JochenAdministrator
(KiX Supporter)
2001-10-16 01:19 PM
Re: Using admin rights in script

Eleyland,

this is nothing I'd do in a logon script, as it seems to be a single run task !
I'd run this from an admin Workstation with a list of Workstation to loop and achieving results either by using adsi methods,
or even a temporary install of RCMD on the Clients ...
Much better than using SU ( It's a pain in the A** IMHO)

For the adsi strategy : Bryce ? Shawn ? Anybody ?

using a temp RCMD installation:

code:

;somewhere in the loop (readline a list of Clients) ...
;$share is '\\$client\admin$$'
;$client is the client ws name (assuming it has already been mapped earlier in the loop)
;$bin is the folder where Oemnsvrc.inf and rcmdsvc.exe are resident
;you should have xnet.exe and rcmd.exe in path (..\system32)

copy $bin + '\oemnsvrc.inf' $share + '\system32\'
if @error
'$client : Copy of Oemnsvrc.inf failed' ?
goto skip
else
copy $bin + '\rcmdsvc.exe.inf' $share + '\system32\'
if @error
'$client : Copy of rcmdsvc.exe failed' ?
goto skip
else
shell '%ComSpec% /c xnet install \\' + $client + '\RemoteCmd /b:Rcmdsvc.exe /d:LanmanServer /n:"Remote Command Server" /u:LocalSystem /s:auto >nul'
if @error
'$client : Installation of RCMD failed' ?
goto skip
else
shell '%ComSpec% /c xnet start \\' + $client + '\RemoteCmd >nul'
if @error
'$client : starting RCMD failed' ?
goto skip
else
shell '%ComSpec% /c rcmd \\' + $client + ' net localgroup administrators "DOMAIN\Local ADMIN GROUP" /delete >%0\..\dummy.txt'
if @error = 1 ; rcmd returns 1 on success !!!
shell '%Comspec% /c type %0\..\dummy.txt |find /C "successfully." >nul'
if @error
'$client : unable to remove global group' ?
else
'$client : done !' ?
endif
else
'$client : executing net localgroup failed' ?
goto skip
endif
endif
endif
endif
endif
:skip
shell '%ComSpec% /c xnet stop \\' + $client + '\RemoteCmd >nul'
shell '%ComSpec% /c xnet remove \\' + $client + '\RemoteCmd /y >nul'
del $share + '\system32\Oemnsvrc.inf'
del $share + '\system32\rcmdsvc.exe'
use $share /delete
loop


Hth

Jochen

[ 16 October 2001: Message edited by: jpols ]

[ 16 October 2001: Message edited by: jpols ]