Solved

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

Posted on 2004-08-02
2
213 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
A Short Story about the Best File Recovery Software – Acronis True Image 2017
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

707 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

12 Experts available now in Live!

Get 1:1 Help Now