.bat script service status

The following script demonstrates how to query NT Service Controller for service status. This script was used to check if the application (service) is running and if not install. msi package. Basic logging is also included.
You might need to find out service name. To do so issue the following cmd command to list all services:
sc query


@echo ON
REM Created: Dec 08, 2009
REM Author: Naz Snidanko
REM Descrp: Query service and install .msi
SC QUERY Printelligence | FIND "STATE" > null

if %errorlevel% EQU 0 goto Good1
if %errorlevel% EQU 1 goto NotGood1

goto DoNe
echo %COMPUTERNAME% from %username% Deployment >> \\syslogserver\XEROX\log.txt
msiexec /i "\\zeus\Support\naz\script\xerox\Xerox Print Environment Assessor.msi"
echo Started %date% %time% >> \\syslogserver\XEROX\log.txt

Hope it helps!

This entry was posted in .bat scripts, Random stuff and tagged , , . Bookmark the permalink.

4 Responses to .bat script service status

  1. Wahrsager says:

    Many thanks for this fantastic publish. It contains many data which I will need. I am bookmark your website by my next visit.

  2. watch chef says:

    Link exchange is nothing else however it is just placing the other person’s weblog link
    on your page at suitable place and other person will also do
    same in support of you.

    Also visit my weblog watch chef

  3. Lorene says:

    What’s up everyone, it’s my first visit at this site, and piece of writing is genuinely fruitful for
    me, keep up posting such articles or reviews.

    Here is my web blog; social landings (Lorene)

Leave a Reply

Your email address will not be published. Required fields are marked *