here is a new UDF I want to share. RCMDInstall()
RCMDInstall will install the RCMD service on to a target computer.
By using the RCMD service you will be able to execute a command on a target.
This is just the start of a homegrown SMS service that i am working on.... more will follow!
code:
function RCMDInstall($target, OPTIONAL $targetadmin, OPTIONAL $targetpassword)
;
; RCMDInstall, this function will intall the RCMD service onto a target NT/w2k
; computer.
;
; SYNTAX: RCMDInstall(<target>, [<target username>],[<target password>])
;
; Parameters: <target> is the unc name of the computer to install RCMD on
;
; <target name> is an optional username used to gain access to a remote
; target computer.
;
; <target password> is the password used for the <target name>
;
; Returns: Returns nothing but but check @error for detailed information
;
; Example: ;this will install the RCMD service on \\testserver using inherited
; ;accress rights
; RCMDInstall("\\testserver")
;
; ;This will install the RCMD service on \\testserver even through
; ;\\testserver is in a different DOMAIN
; RCMDInstall("\\testserver", "houston\smithb", "1234")
;
; ;this will install the RCMD service on \\testserver using the local
; ;administrator account
; RCMDInstall("\\testserver","administrator","1234")
;
; Remarks: * RCMD.EXE and RCMDSVC.exe must be in the same local folder of the script
; * Xnet.exe must be avaliable in the path DIM $target, $targetname, $targetadmin, $targetpassword, $targetsystemroot
if substr($target,1,2) <> "\\"
exit(11)
else
$targetname = substr($target,3,len($target))
endif
IF $targetadmin <> ""
if instr($targetadmin,"\") = 0
use "$target\ipc$$" /user:'$targetname\$targetadmin' /password:$targetPassword
else
use "$target\ipc$$" /user:'$targetadmin' /password:$targetPassword
endif
else
use "$target\ipc$$"
endif
Select
case @error = 0
;install the RCMD service on the $target computer
$targetSystemRoot = readvalue("$target\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\","SystemRoot")
shell '%comspec% /c xnet list $target | find /i "rcmdsvc" > nul'
if @error = 0
shell '%comspec% /c xnet stop $target\rcmdsvc > nul'
shell '%comspec% /c xnet remove $target\rcmdsvc /y > nul'
endif
if exist("RCMD.exe") AND exist("RCMDSVC.exe")
copy "rcmd*.exe" "$target\admin$$\system32"
else
exit(2)
endif
if @error <> 0 exit(@error) endif
shell '%comspec% /c xnet install $target\rcmdsvc /b:$targetsystemroot\system32\rcmdsvc.exe /n:"Remote Command Service" /u:localsystem /i:n /s:auto > nul'
shell '%comspec% /c xnet start $target\rcmdsvc > nul'
case @error <> 0
;unable to make an admin connection to the $target computer
exit(@error)
endselect
use "$target\ipc$$" /delete
endfunction
Bryce