How to check windows services using batch file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
674777
Posts: 1
Joined: 13 Jan 2014 16:59

How to check windows services using batch file

#1 Post by 674777 » 13 Jan 2014 17:05

Hi Everyone,

I want to create a batch file which could perform below task:-

    check the status of windows services.
    close one running application and start it again.
    check for a particular file in a directory.

optional
send mail to a particular mail id.

Any help would be appreciated.

Thanks in advance.. :)

ShadowThief
Expert
Posts: 1163
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: How to check windows services using batch file

#2 Post by ShadowThief » 13 Jan 2014 18:10

http://ss64.com/nt/tasklist.html
http://ss64.com/nt/taskkill.html
and also start.html, but I'm only allowed to post two URLs per post.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: How to check windows services using batch file

#3 Post by foxidrive » 14 Jan 2014 01:19

To get help on SC for querying services: sc /?
To get help on how to close an application: taskkill /?
To check for a file in a folder:

Code: Select all

if exist "c:\folder\file.ext" echo yep! That's there.

To send an email you need a third party tool like BLAT or SENDMAIL or a VBS script and Powershell may work too, but I haven't tried Powershell for that.

penpen
Expert
Posts: 1996
Joined: 23 Jun 2013 06:15
Location: Germany

Re: How to check windows services using batch file

#4 Post by penpen » 14 Jan 2014 05:15

You may use VBScript to email:
http://www.dostips.com/forum/viewtopic.php?p=31134#p31134
You just have to set the Configuration.Fields as you need it.
The code is near the end of the linked post.

penpen

Post Reply