Solved

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

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows 2000 Print Server 2 1,059
Software to report on NTFS folder permissions? 2 497
how to run this deletion request 4 39
Promote Server 2012 R2 on Server 2003 domain 13 27
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…
The world seems to conceive of a curious bubble separating IT from “the business.”  More so than just about any other pursuit in the commercial world, people think of IT as some kind of an island.

730 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