Windows command to get service status


I need to know the status of a service at the end of my batch script which restarts services using "net stop thingie" and "net start thingie".

In my most favorite ideal world, I would like to e-mail the state to myself, to read on cold winter nights, to reassure myself with the warmth and comfort of a server that I know is running right.

Just for you to know, I'm using a Windows server 2003 platform, and a batch file seemed the best choice. I don't mind using something else, and would be very open to suggestions, but just for the sake of knowledge (as a zombie craves brains, I thought, why not inflate my own), is there a command that allows me to check on the status of a service, in command line?

Should I just redirect the output of the command to a file?

Where the hell are my pants? (Gosh, I really do hope the humor inserted in this will not insult anyone. It's Wednesday morning, and humor I do need too :P)

[Edit:] The solution I used is (no longer) available for download from –link redacted–

It is used as a task set to be executed during the night, and checking my e-mail in the morning, I see whether or not the service has correctly restarted.

Best Solution

Have you tried sc.exe?

C:\> for /f "tokens=2*" %a in ('sc query audiosrv ^| findstr STATE') do echo %b

C:\> for /f "tokens=2*" %a in ('sc query sharedaccess ^| findstr STATE') do echo %b

Note that inside a batch file you'd double each percent sign.