我需要在远程计算机上运行一个应用程序或服务。我已经成功地使用过SysInternals的psexec,但我正在调查并希望了解更多替代方案。 最终这个命令将从Delphi应用程序中运行。谢谢,Pieter。
我需要在远程计算机上运行一个应用程序或服务。我已经成功地使用过SysInternals的psexec,但我正在调查并希望了解更多替代方案。 最终这个命令将从Delphi应用程序中运行。谢谢,Pieter。
' 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
如果您需要传输任何敏感信息,ssh是一个不错的选择。甚至有一些适用于Windows的自由软件SSH服务器,它们不依赖于Cygwin。
AT \\server 4:00 "c:\something.bat"