本文介绍了Windows命令,以获取服务状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道服务中的我的批处理脚本的末尾用净停止的thingie与净启动的thingie。

I need to know the status of a service at the end of my batch script which restarts services using "net stop thingie" and "net start thingie".

在我最喜欢的理想世界,我想以电子邮件的状态自己,在寒冷的冬夜阅读,我知道正在运行正确的服务器的温暖和安慰安慰自己。

In my most favorite ideal world, I would like to e-mail the state to myself, to read on cold winter nights, to reassure myself with the warmth and comfort of a server that I know is running right.

只是让你知道,我使用的是Windows Server 2003平台,以及一个批处理文件似乎是最好的选择。我不介意使用别的东西,并且将建议非常开放,但只是对知识的缘故(如僵尸渴望的大脑,我想,为什么不吹我自己),是有一个命令,让我检查在一个服务的状态,在命令行?

Just for you to know, I'm using a Windows server 2003 platform, and a batch file seemed the best choice. I don't mind using something else, and would be very open to suggestions, but just for the sake of knowledge (as a zombie craves brains, I thought, why not inflate my own), is there a command that allows me to check on the status of a service, in command line?

如果我只是命令的输出重定向到一个文件?

Should I just redirect the output of the command to a file?

到底在哪儿是我的裤子? (天哪,我真的希望插入这不会侮辱任何人的幽默今天是星期三上午和幽默我确实需要太:P)

Where the hell are my pants? (Gosh, I really do hope the humor inserted in this will not insult anyone. It's Wednesday morning, and humor I do need too :P)

我用的解决方案是(不再),可以用于下载--link节录 -

The solution I used is (no longer) available for download from --link redacted--

它被用作设置在夜间执行任务,并检查我的电子邮件早上,我看到服务是否已正确地重新启动。

It is used as a task set to be executed during the night, and checking my e-mail in the morning, I see whether or not the service has correctly restarted.

推荐答案

使用Windows脚本:

Using Windows Script:

Set ComputerObj = GetObject("WinNT://MYCOMPUTER")
ComputerObj.Filter = Array("Service")
For Each Service in ComputerObj
    WScript.Echo "Service display name = " & Service.DisplayName
    WScript.Echo "Service account name = " & Service.ServiceAccountName
    WScript.Echo "Service executable   = " & Service.Path
    WScript.Echo "Current status       = " & Service.Status
Next

您可以轻松地过滤上述所需的特定服务。

You can easily filter the above for the specific service you want.

这篇关于Windows命令,以获取服务状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 06:38