Solved

Sugg on service status query & Some batch file help...

Posted on 2004-08-02
2
214 Views
Last Modified: 2010-04-13
1. How to query particualr service status using WMI
here i have the Script for getting all service status ...But I am looking for specific service status...Not all
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Service",,48)
For Each objItem in colItems
    Wscript.Echo "DisplayName: " & objItem.DisplayName
    Wscript.Echo "StartMode: " & objItem.StartMode
    Wscript.Echo "State: " & objItem.State
Next
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

otherwise I got a output like this....

+++++++++++++++++++++++++++++++++++++++++
DisplayName: Enterprise Security Agent
StartMode: Auto
State: Running
DisplayName: Event Log
StartMode: Auto
State: Running
DisplayName: COM+ Event System
StartMode: Manual
State: Running
DisplayName: Fax Service
StartMode: Manual
State: Stopped
DisplayName: HP ITO Agent
StartMode: Auto
State: Running
DisplayName: IIS Admin Service
StartMode: Auto
State: Running
++++++++++++++++++++++++++++++++++++++++++++

Here i can get the service name using Findstr "DisplayName: IIS Admin Service". but how i can i get the next two line.
If i search for "StartMode: Auto" or "State: Running" it is goign to list all keys.

what i want is like this search for "DisplayName: Enterprise Security Agent"  which is  line 1 and print
the print line2 & line3 which is for Enterprise Security Agent.

then search for "DisplayName: Fax Service" which is "line 10" which is and print
the print line10 & line11 which is for Fax Service

how to do this in batch file.....
0
Comment
Question by:moorthy_kulumani
2 Comments
 
LVL 41

Accepted Solution

by:
graye earned 125 total points
ID: 11694934
It's about what you'd expect from an SQL style query.... change the line to read:

Set colItems = objWMIService.ExecQuery("Select * from Win32_Service where DisplayName='IIS Admin Service'",,48)
                                                                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^
0
 
LVL 3

Author Comment

by:moorthy_kulumani
ID: 11701558
Thanks I might need some more help later on with WMI , Exchange , IIS  
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now