通过运行PSEXEC在cmd中多张命令 [英] Running mulitple commands in cmd via 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.
- 使用PSEXEC来访问远程计算机
- 前往正确的目录和文件
- 执行Ant任务
- 退出CMD
- 在一行中一起跑
我可以运行,从运行下面的命令来完成我需要什么成就,但似乎无法得到正确格式为PSEXEC去了解它。
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
我已经试过这appling下面的PSEXEC例如:
I've tried appling this to the psexec example below:
psexec \\machine cmd /K cd /d D:\directory & ant & exit
在执行这个它会激活命令行,前往 D:\\目录
,但不会执行剩余的命令。添加,
刚刚产生更多的问题。
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.
任何人都可以指引我正确的格式?或比其他PSEXEC东西我可以用它来完成这个(仅适用于自由选择)?
Can anyone guide me to the correct format? Or something other than psexec I can use to complete this (free options only)?
推荐答案
想通了之后终于有了一些更多的互联网搜索和反复试验。 PSEXEC需要/ C运行多个命令,但该语法不与我上面写的安装工作。我已经得到了下面的命令来运行我需要什么。
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.
psexec \\machine cmd /c (^d:^ ^& cd directory^ ^& ant^)
我不应该退出,因为PSEXEC会结束后退出本身。您还可以使用&功放;&安培;需要成功,继续到下一个命令。发现这个论坛有帮助
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
<一个href=\"http://forum.sysinternals.com/psexec_topic318.html\">http://forum.sysinternals.com/psexec_topic318.html
这对于运行PSEXEC命令
And this for running psexec commands
http://ss64.com/nt/psexec.html
这篇关于通过运行PSEXEC在cmd中多张命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!