paurat
asked on
Batch file to list specific running services
Hi, I need a batch file to be able to extract a list of machine names from the 'online.txt' file, ie,
for /f %%A in ('type "online.txt"') do (sc \\%%A query "servicename" | find "RUNNING")
then query a specific list of services running on remote machines, and output the results on screen. eg,
<MACHINENAME> <SERVICE> <RUNNING>
for /f %%A in ('type "online.txt"') do (sc \\%%A query "servicename" | find "RUNNING")
then query a specific list of services running on remote machines, and output the results on screen. eg,
<MACHINENAME> <SERVICE> <RUNNING>
ASKER
I am liking this....., but I could really do with looking for four specific services. eg, Print Spooler, McShield, + another 2 (that have not been decided on yet!). The output from listing all the services on the machines on the list would be a little too long to sort through on a daily basis.
Other than this minor point, the output from your script is perfect.
SERVICE_NAME: Spooler
DISPLAY_NAME: Print Spooler
TYPE : 110 WIN32_OWN_PROCESS (interactive)
STATE : 4 RUNNING
(STOPPABLE,NOT_PAUSABLE,AC CEPTS_SHUT DOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
Other than this minor point, the output from your script is perfect.
SERVICE_NAME: Spooler
DISPLAY_NAME: Print Spooler
TYPE : 110 WIN32_OWN_PROCESS (interactive)
STATE : 4 RUNNING
(STOPPABLE,NOT_PAUSABLE,AC
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
All yours. Many thanks.
default sc query is running services
stopped services
sc query state= inactive
all services
sc query state= all
Open in new window