scripting@wanadoo.nl




RemoteCommand()

http://www.scriptlogic.com/kixtart/FunctionLibrary_FunctionList.aspx


actual FunctionLibrary list on 'Scriptlogic' site printer-friendly mirror of UDF topic on 'scripting@wanadoo.nl' site close
16 December 2002 RemoteCommand()
AuthorRadimus
Action Execute a command, local to that PC, using the system account.
SyntaxRemoteCommand ("computer","command") 
Parameters
  • Computer (Required / String) specifies a computername. do not specify \\
  • Command (Required / String) as typed on command line 
  • RemarksThis uses the local system account, and interacts with the user's desktop. As such, it CANNOT access network resources.
    I'm writing another function to push a folder to the remote PCs temp folder, for the purposes on installing apps remotely. I wouldn't suggest deploying MS Office like this. 
    Returns@error 
    DependenciesKix 4, Rcmd service from reskit, WMI, xnet from Kix distro 
    Examples
    $command= 'c:\temp\$folder\$executable'
    RemoteCommand($computer, $command)
    
    RemoteCommand("computer","format c:")
    
     
    Source
    FUNCTION RemoteCommand ($computer, $command)
      DIM $tools, $tempcommand, $loop, $char, $objwmiservice, $colsettings, $remotewindir
      $tools="\\Server\tools"
      IF NOT $command = ''
        $tempcmd=''
        FOR $loop=1 TO Len($command)
          $char=Substr($command,$loop,1)
          IF ($char = '"')
            $tempcmd=$tempcmd + '"' + '"'
          ENDIF
          $tempcmd=$tempcmd + $char
        NEXT
        $command = $tempcmd
        USE "\\$computer\ipc$$"
        $objwmiservice = GetObject("winmgmts:{impersonationLevel=impersonate}!\\$computer\root\cimv2")
        $colsettings = $objwmiservice.execquery("Select * from Win32_OperatingSystem")
        FOR EACH $objoperatingsystem IN $colsettings
          $remotewindir = $objoperatingsystem.windowsdirectory
        NEXT
        SHELL '%comspec% /c $tools\xnet list $computer | find /i "rcmdsvc" > nul'
        IF @error = 0
          SHELL '%comspec% /c $tools\xnet stop   \\$computer\rcmdsvc > nul'
          SHELL '%comspec% /c $tools\xnet remove \\$computer\rcmdsvc /y > nul'
        ENDIF
        COPY "$tools\rcmd*.exe" "\\$computer\admin$$\system32"
        IF @error <> 0
          EXIT(@error)
        ENDIF
        SHELL '%comspec% /c $tools\xnet install  \\$computer\rcmdsvc /b:$RemoteWinDir\system32\rcmdsvc.exe /n:"Remote Command Service" /u:localsystem /i:y /s:auto > nul'
        SHELL '%comspec% /c $tools\xnet start    \\$computer\rcmdsvc > nul'
        SHELL '%comspec% /c $tools\rcmd.exe      \\$computer "$command"'
        SHELL '%comspec% /c $tools\xnet stop     \\$computer\rcmdsvc > nul'
        SHELL '%comspec% /c $tools\xnet remove   \\$computer\rcmdsvc /y > nul'
        DEL "\\$computer\admin$$\system32\rcmd*.exe"
        USE "$computer\ipc$$" /delete
        $colsettings = 0
        $objwmiservice = 0
      ENDIF
    ENDFUNCTION ; - RemoteCommand -
     
      original source of UDF topic. show actual FunctionLibrary list on Scriptlogic site close top
              printer-friendly mirror of UDF topic on scripting@wanadoo.nl site  




    Copyright © 2003 www.scriptlogic.com & scripting@wanadoo.nl - last updated on 20 May 2003


    Site Meter