Run application or Process on a remote computer

后端 未结 3 1073
闹比i
闹比i 2020-12-30 16:42

I need to run an application or service on a remote computer. I have had success with psexec from SysInternals, but I am investigating and would like to compre alternatives.

相关标签:
3条回答
  • 2020-12-30 17:33

    The other possiblity would be to use the windows AT command which schedules tasks via the windows scheduler. You can submit jobs remotely with the command as long as you have administrator access and the schedule service is running on the other machine. To examine the syntax, just open a CMD window and type AT /?.

    for example to run something on machine named "server" at 4am, just enter the command

    AT \\server 4:00 "c:\something.bat"
    
    0 讨论(0)
  • 2020-12-30 17:42

    ssh is a good choice if you will be streaming anything sensitive. There are even a few FOSS sshd servers for windows that do not rely on cygwin.

    0 讨论(0)
  • 2020-12-30 17:44

    If you want to follow the PSexec-like route, here is an example (with C++) source, called XCmd.

    Or you can download the updated XCmd project (now called 'The Grim Linker') from SourceForge.

    Essentially, it extracts a service at run-time, copies it to the remote system, installs it as a service, then connects to it (via named Pipes).

    The other option is to use WMI's built-in remote execution abilities. Here is an example in VBScript that you could convert to Delphi. The example below executes notepad on the remote system.

    ' This script provides a function for executing a command on a remote computer
    ' This uses WMI and requires that you have administrative righs on the remote machine
    '
    
    Dim strComputer, strCommandLineToRun
    
    'change the period to an IP Address or computer name
    strComputer = "."   'example: strComputer = "192.168.1.105"
    
    'this is the path to the file on the computer whose name/IP address is stored in the strComputer variable
    strCommandLineToRun = "c:\windows\system32\calc.exe"
    
    
    ' This calls the function to run the process on a remote computer
    RemoteExecute strComputer,"","",strCommandLineToRun
    
    
    Function RemoteExecute(strServer, strUser, strPassword, CmdLine)
        Const Impersonate = 3
    
        RemoteExecute = -1
    
        Set Locator = CreateObject("WbemScripting.SWbemLocator")
        Set Service = Locator.ConnectServer(strServer, "root\cimv2", strUser, strPassword)
    
        Service.Security_.ImpersonationLevel = Impersonate 
        Set Process = Service.Get("Win32_Process")
    
        result = Process.Create(CmdLine, , , ProcessId)
    
        If (result <> 0) Then
            WScript.Echo "Creating Remote Process Failed: " & result
            Wscript.Quit
        End If
    
        RemoteExecute = ProcessId
    End Function
    
    0 讨论(0)
提交回复
热议问题