|
| |||||||||
| Tags: batch file, batch file, defragging drives, dos commands, notepad, start, start, stop, stop |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| ||||
| ||||
| Start and Stop Services in a single batch file?
Hello Friends, I was wondering, that is it possible to start or stop a service using a single batch file.?? Can I use the "if" type structure to do the both services in one batch file.?? I am very new to this batch files, so hoping that someone can help me out.! Please help me as soon as possible.! ![]()
__________________ We endorse perversion and call it an alternative lifestyle We kill our unborn and call it choice We neglect to discipline our children and call it building self-esteem We pollute the air with profanity and pornography and call it freedom of expression |
|
#2
| ||||
| ||||
| Re: Start and Stop Services in a single batch file?
You can create the batch files to schedule all sorts of things from Defragging drives, to performing backups, stopping services on servers, etc. The batch files are made like the DOS commands. In other words, you can say that the batch file is made of the exact same commands. Here is an example : Code: h: cd\retros~1 copy *.* c:\retrocpy /V/Y
__________________ The FIFA Manager 2009 PC Game |
|
#3
| ||||
| ||||
| Re: Start and Stop Services in a single batch file?
I think that you can use the following code for Start and Stop Services in a single batch file. You will have to create a batch file as mentioned by the 'opaper'. The following coding you will have to save in the Notepad and then save it as Batch file. Here is the coding Code: IF "service"==stopped "NET START 'service'" IF "service"==started "NET STOP 'service'" |
|
#4
| |||
| |||
| Re: Start and Stop Services in a single batch file?
Instead of using the Code: IF "service"==stopped "NET START 'service'" IF "service"==started "NET STOP 'service'" Code: NET START "service" || NET STOP "service" |
|
#5
| ||||
| ||||
| Re: Start and Stop Services in a single batch file?
You can also use the following code. Code: sc query service | findstr /i running | if "%errorlevel%"=="0" (sc stop service) else (sc start service) |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Start and Stop Services in a single batch file?" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Windows XP - Network connection services failed to start...Error 2: File cannot be found | jayarect | Operating Systems | 1 | 4 Weeks Ago 07:05 AM |
| How to Start and Stop Gnome GUI Services | Lilija | Operating Systems | 4 | 12-11-2010 07:30 AM |
| How to Win XP services Start, Stop, Manual, Pause and Resume | RasMus | Operating Systems | 3 | 07-07-2009 09:27 AM |
| VBScript that will stop then start two services and pop up a message box afterwards | Spin | Windows Server Help | 5 | 24-04-2009 05:45 AM |
| win2ksp4 - cannot stop/start services, install/uninstall software,use Internet Explorer | Jim | Window 2000 Help | 12 | 23-08-2005 01:29 AM |