如何在工作站上自动执行任务列表命令来检查 X 台服务器上的特定进程?
我正在尝试检查 XenApp 服务器上 spoolsv.exe 进程的状态。我已经从我的 XP 工作站上单独运行了该命令,但似乎无法让它迭代文本文件。这是我到目前为止所拥有的,什么会使其在我的 CMD 屏幕上填充服务器 X-XX?
@echo off
FOR /F "usebackq" %%G IN ("C:\Documents and Settings\userid\Desktop\Scripts\servers.txt") DO echo tasklist /S %%G /u domain\userid | find "spoolsv.exe"
pause
我似乎无法让它正确运行,有时它只会在记事本中弹出我的servers.txt 文件,甚至无法运行。我缺少什么?
I'm trying to check what the status is on my XenApp servers for the spoolsv.exe process. I've got the command down to run individually from my XP workstation, but can't seem to get it to iterate through a text file. Here's what I have so far, what will make this populate Servers X-XX on my CMD screen?
@echo off
FOR /F "usebackq" %%G IN ("C:\Documents and Settings\userid\Desktop\Scripts\servers.txt") DO echo tasklist /S %%G /u domain\userid | find "spoolsv.exe"
pause
I can't seem to get it to run correctly, and sometimes it will just pop up my servers.txt file in notepad and not even run. What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如您所呈现的,任务列表永远不会运行。 “do echo tasklist...”片段意味着文字字符串“tasklist /S server-one...”正在被回显到标准输出。由于这些文字字符串都不包含“spoolsv.exe”,因此“find”命令不会匹配任何内容。
请尝试以下方法:
As you have it presented, tasklist never runs. The "do echo tasklist..." snippet means the literal string "tasklist /S server-one..." is being echo'ed to stdout. Since none of these literal strings contain "spoolsv.exe", the "find" command won't match anything.
Try the following instead: