Running an application or process on a remote computer

I need to run an application or service on a remote computer. I have had success with pysxec from SysInternals, but I am learning and would like to make alternatives. Ultimately, the command will be launched from the Delphi application. Thanks, Peter.

+4
source share
3 answers

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

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

, , , , ( ).

- WMI . VBScript, Delphi. .

' 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
+3

ssh - , - . FOSS sshd- Windows, cygwin.

+2

Another possibility would be to use the windows AT command, which schedules tasks through the window scheduler. You can send tasks remotely using a command as long as you have administrator access and the schedule service is running on another computer. To learn the syntax, just open the CMD window and type AT /? .

for example, to run something on a machine called "server" at 4 a.m., just type

AT \\server 4:00 "c:\something.bat"
0
source

All Articles