如何从Windows发送命令到Windows

如何从Windows计算机在其他Windows计算机上编写远程命令脚本?

例如,在* nix- * nixnetworking上,我可以执行ssh wu@otherbox foo ,并且提供密钥设置正确, foo运行并且ssh客户端返回返回代码。

psexec – http://technet.microsoft.com/en-us/sysinternals/bb897553

PsExec是一个轻量级的telnetreplace程序,可让您在其他系统上执行进程,并为控制台应用程序提供完整的交互性,而无需手动安装客户端软件。

另一个select是编写一个PowerShell或VBScript(使用WMI)。

WMI命令行工具是一个不错的select:

 wmic.exe /node:somecomputer process call create "c:\bin\uphclean\uphclean.exe -install" 

您应该查看PSExec实用程序。

如果您正在寻找脚本方法,还有另一种方法。 除了psexec和wmic之外,这可以通过powershell完成。 远程PowerShell只适用于Windows 7,可能是Vista,绝对是Server 2008。

 invoke-command -computername YourTarget01 -scriptblock { $Object=get-something $Wibble $Data1=$Object.method } 

要使用它,需要在目标机器上打开并configurationWinRM。 这东西可以通过GPO推送,所以你不必手工configuration。 方便大规模部署。 对于复杂的操作,创build单个会话对象是一个好主意,因此每次碰到机器时都不会跳出一个新对话框:

 $Session=new-pssession -ComputerName YourTarget01 invoke-command -Session $Session -Scriptblock { } 

默认情况下,凭据是调用者的凭证,但其他的凭证可以被指定为选项。