Page 1 of 1 1
Topic Options
#13198 - 2001-10-15 01:44 PM Using admin rights in script
Anonymous
Unregistered


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

Top
#13199 - 2001-10-15 02:09 PM Re: Using admin rights in script
Anonymous
Unregistered


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

//robban

Top
#13200 - 2001-10-16 05:59 AM Re: Using admin rights in script
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
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 ..."

_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#13201 - 2001-10-16 01:19 PM Re: Using admin rights in script
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
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 ]

_________________________



Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 382 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.201 seconds in which 0.172 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org