通过 psexec 在 cmd 中运行多个命令
我正在努力创建一个命令,该命令将在另一台计算机的命令行上运行多项操作。这就是我想做的事情。
- 使用 psexec 访问远程计算机
- ,移动到正确的目录并文件
- 执行 ant task
- exit cmd
- 在一行中一起运行
我可以从 Run 运行以下命令来完成我需要完成的任务,但似乎无法获得 psexec 理解的正确格式它。
cmd /K cd /d D:\directory & ant & exit
我尝试将此应用于下面的 psexec 示例:
psexec \\machine cmd /K cd /d D:\directory & ant & exit
执行此示例时,它将激活命令行并前往 D:\directory,但不会执行其余命令。添加 ""
只会产生更多问题。
谁能指导我正确的格式?或者我可以使用 psexec 以外的其他东西来完成此操作(仅限免费选项)?
I'm working on creating a single command that will run mulitple things on the command line of another machine. Here is what I'm looking to do.
- Use psexec to access remote machine
- travel to proper directory and file
- execute ant task
- exit cmd
- run together in one line
I can run the below command from Run to complete what I need accomplished but can't seem to get the format correct for psexec to understand it.
cmd /K cd /d D:\directory & ant & exit
I've tried appling this to the psexec example below:
psexec \\machine cmd /K cd /d D:\directory & ant & exit
When executing this it will activate the command line and travel to D:\directory
but won't execute the remaining commands. Adding ""
just creates more issues.
Can anyone guide me to the correct format? Or something other than psexec I can use to complete this (free options only)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
经过一番网上搜索和反复试验后终于弄清楚了。 psexec 需要 /c 来运行多个命令,但该语法不适用于我上面编写的设置。我已经得到下面的命令来运行我需要的东西。
我不需要退出,因为 psexec 会在完成后自行退出。您还可以使用 &&要求成功才能继续执行下一个命令。发现这个论坛很有帮助
http://forum。 sysinternals.com/psexec_topic318.html
这用于运行 psexec 命令
http://ss64.com/nt/psexec.html
Figured it out finally after some more internet searching and trial and error. psexec needs /c to run multiple commands, but that syntax doesn't work with the setup I wrote above. I've gotten the below command to run what I need.
I don't need to exit because psexec will exit itself upon completion. You can also use && to require success to continue on to the next command. Found this forum helpful
http://forum.sysinternals.com/psexec_topic318.html
And this for running psexec commands
http://ss64.com/nt/psexec.html
这有效:
psexec \ComputerName cmd /c "echo hey1 & echo hey2"
This works:
psexec \ComputerName cmd /c "echo hey1 & echo hey2"
对于简单的情况,我使用:
对于更复杂的情况,使用带有 PsExec 的
-c 的批处理文件
switch 可能更合适:For simple cases I use:
For more complex cases, using a batch file with PsExec's
-c
switch may be more suitable:既然您询问了其他选项并且这具有标签配置管理 - 我想您可能对 Jenkins (或哈德森)。它提供了创建主从机制的非常好的方法,这可能有助于简化构建过程。
Since you asked about other options and this has tag configuration managment-- I guess you may be interested in Jenkins (or Hudson). It provide very good way of creating master-slave mechanism which may help in simplifying the build process.
我总是这样使用:)并且工作正常
I always use like this way :) and works properly