# Figure Out If Service Is Running With Batch File



## goldhat (Aug 12, 2007)

hi im trying to make a batch file check if a certain service is started and if it goto
say line :ServiceStarted

but if the service is not started make it say go to line :ServiceNotStarted

also im dont know if this is even with external utilitys
i want when somebody clicks on the X to exit it runs a command then exits

OR 

i want to disable clicking the X to close


thx soooo muchhhh in advance


----------



## Squashman (Apr 4, 2003)

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/sc.mspx?mfr=true



> Using SC, you can query the service status and retrieve the values stored in the status structure fields. Services.exe cannot provide you with the complete status of a service, but SC shows the exact state of the service


----------



## goldhat (Aug 12, 2007)

i dont understand what do i do


----------



## Squashman (Apr 4, 2003)

I see from other posts that you know what the SC command is. If you don't understand Microsoft's documentation, Google search and read more about it.
http://www.ss64.com/nt/sc.html


----------



## goldhat (Aug 12, 2007)

please tell me the answer i know a little bit about the sc command but not enough


----------



## fruhs (Oct 4, 2007)

Here is a quick way to find out if a service is running using "net start" cmd

http://www.fpschultze.de/smartfaq+faq.faqid+187+PHPSESSID+a42799e0bc51fe83edf7371037c9632e.htm


----------

