Computing.Net > Forums > Programming > Batch file to start and stop servic

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch file to start and stop servic

Reply to Message Icon

Name: niksu444
Date: October 30, 2007 at 22:21:55 Pacific
OS: Windows XP
CPU/Ram: Intel P4
Product: Dell
Comment:

Hi!

I need a batch file to start and stop some specifig service. The service could be in example messenger.

I have now tried to make it with the guide of http://www.ss64.com/nt/sc.html which guides me to make it using SC and FIND command. And managed to get this kind of code:

SC query messenger | FIND "STATE"
goto task%errorlevel%
:task0
NET STOP messenger
goto end
:task1
NET START messenger
:end
exit

for some reason this aint working. The errorlevel status doesnt change. It is the same still even if the service is on or off.

Can this be done in some other way, or is there something I am doing wrong?

Please help :)



Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: October 30, 2007 at 22:29:22 Pacific
Reply:

Try this (untested):

NET START messenger ||NET STOP messenger



0

Response Number 2
Name: niksu444
Date: November 6, 2007 at 21:36:13 Pacific
Reply:

Yes it worked!

Thank you very much, should always first try to look simple answers :D


0

Response Number 3
Name: Sweetheart
Date: November 16, 2007 at 12:18:04 Pacific
Reply:

I have a somwhat similar problem. Need to stop a service while running a backup. When I Net Stop "Service" it responds with a message that a running service is dependent on it--we knew--and wants a "Y" or "N" to continue. How can I work the answer into the batch file so it is an unattended PRE-Command for Backup Exec?

Any help appreciated


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch file to start and stop servic

Batch File to open and move .ttf fi www.computing.net/answers/programming/batch-file-to-open-and-move-ttf-fi/12043.html

Batch File to Parse and Write back www.computing.net/answers/programming/batch-file-to-parse-and-write-back/18101.html

Batch file to run program www.computing.net/answers/programming/batch-file-to-run-program/15407.html