如何在 Windows 中远程执行脚本?
我想让 Windows 2003 服务器触发一个脚本,以触发另一台 Windows Server 2008 计算机中的另一个脚本。
有人告诉我 Powershell 可以做到这一点,这很好,但我需要更具体的细节。
有人对此有什么建议吗?
谢谢!
I would like to have a Windows 2003 server fire a script to fire another script in a separate Windows Server 2008 computer.
I have been told that Powershell can do that, and that's fine, but I need more specific details.
Does anyone have any tips for this?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
来自 SysInternals 的 psexec
psexec from SysInternals
查看 AT 命令的语法。 您可以使用它来安排进程在远程计算机上运行。
AT 命令安排命令和程序在计算机上运行
指定的时间和日期。 计划服务必须正在运行才能使用
AT 命令。
Look into the syntax for the AT command. You can use it to schedule a process to run on a remote machine.
The AT command schedules commands and programs to run on a computer at
a specified time and date. The Schedule service must be running to use
the AT command.
最简单的使用方法分为两个步骤
: 将 cygwin 安装到远程电脑
b. 运行 ssh hudson@mcs '/cygdrive/c/path_to_script.bat'
easiest way that is use will be in two steps
a. installing cygwin to remote pc
b. run ssh hudson@mcs '/cygdrive/c/path_to_script.bat'
说到
PsExec
,我强烈建议改用 Cygwin/OpenSSH。SSH 具有多种优势(相对于
PsExec
等工具甚至定制服务)。例如,尝试与
PsExec
一起使用并实现这些bash
/ssh
命令行的功能:祝你好运!
SSH 将(!)远程 stdout / stderr / 退出状态传输到本地 shell 进行检查
(将远程执行集成到本地脚本逻辑中的杀手级功能和常见要求)
Cygwin/OpenSSH 提供标准 POSIX shell 环境
(高效的时间投资、基础工具、跨平台准备、兼容习惯等)
您仍然/始终可以运行所有本机 Windows 应用程序
(包括通过
cmd
处理器自动执行*.bat
文件)您可以使用公钥配置无密码身份验证
(考虑无人值守的自动化任务)
提示
我最初遇到了一个需求问题:
后台
sshd
服务必须在用户的图形会话中执行应用程序(使应用程序窗口出现在桌面环境中)。
对我来说可接受的解决方案是直接运行
sshd
服务 在用户的 GUI 会话中(用户登录时自动启动,点击链接查看配置文件更改):
Speaking about
PsExec
, I would strongly suggest to use Cygwin/OpenSSH instead.SSH has multiple advantages (over tools like
PsExec
or even custom-made services).For example, try to use with
PsExec
and implement what thesebash
/ssh
command lines do:Good Luck!
SSH transfers (!) remote stdout / stderr / exit status to local shell for inspection
(killer feature and common requirement to integrate remote execution into logic of local scripts)
Cygwin/OpenSSH provides standard POSIX shell environment
(efficient time investment, fundamental tools, cross-platform ready, compatible habits, etc.)
You can still/always run all native Windows application
(including automatic execution of
*.bat
files bycmd
processor)You can configure password-less auth using public keys
(think about unattended automated tasks)
Tip
There was one requirement I had problems with initially:
background
sshd
service had to execute apps in user's graphical session(to make application window appear in desktop environment).
The acceptable solution for me was running
sshd
service directly in user's GUI session(start automatically when user logs in, follow the link to see configuration file changes):
http://www.experts-exchange.com/OS/ 接受的解决方案Microsoft_Operating_Systems/Q_22959948.html 是:
The accepted solution from http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Q_22959948.html is: