|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#1 |
|
Resident Slacker
Join Date: Dec 2001
Location: Suisun City, California (i know, where the hell is that?!?!?)
Posts: 2,620
|
batch file in 2k
hey everyone,
can someone help me write a batch file that will check to see if a service is running, and if it's not, it'll start it? i have one particular service that stops for seemingly no reason, and until i can find a permanant solution, i figured i could have a batch file run hourly to start it up.
__________________
Friends help you move. REAL friends help you move bodies. - me quite possibly the best book ever written... by me |
|
|
|
|
|
#2 |
|
Barefoot on the Moon!
Staff
Premium Member
Join Date: Aug 2002
Location: Northeastern USA
Posts: 13,384
|
What service?
Start > run type "services.msc" Double click on the service and set it to "automatic"
__________________
There are two secrets to staying young, being happy, and achieving success. You have to laugh and find humor every day, and you have to have a dream.
|
|
|
|
|
|
#3 |
|
Resident Slacker
Join Date: Dec 2001
Location: Suisun City, California (i know, where the hell is that?!?!?)
Posts: 2,620
|
the microsoft information store service on an exchange server. it's set for automatic. it will fail, and the only thing the log says is "this service failed unexpectedly" microsoft has a patch, but when i install it my whole server stops working.
that's why i'd like to run a batch file hourly to check the service, and start it if necessary until i can find a solution. |
|
|
|
|
|
#4 |
|
Staff
Premium Member
Join Date: Jul 1999
Location: Arlington, TN
Posts: 5,538
|
You would have to use the Net commands to get it to work.
net start ServiceName I assume that you could also put a conditional statement in there to test if the service is up first although it probably wouldn't matter if it was already up as it would just error out when trying to start.
__________________
Want to Make $$$$ with your Computer? No Risk! Simply press shift-4 four times in a row |
|
|
|
|
|
#5 |
|
Professional gadfly
|
You can also use the sc command:
sc start "Service" I tried to make a batch file that piped the sc query command through findstr to see if the service was running, but Windows doesn't like putting that kind of construct in an IF statement. What a pain. I think mairving has the right answer in just starting the service without checking to see if it is running yet. |
|
|
|
|
|
#6 |
|
Resident Slacker
Join Date: Dec 2001
Location: Suisun City, California (i know, where the hell is that?!?!?)
Posts: 2,620
|
thanks guys. it won't try and restart the service with that command, will it?
|
|
|
|
|
|
#7 |
|
Staff
Premium Member
Join Date: Jul 1999
Location: Arlington, TN
Posts: 5,538
|
Just run it at the command line to test it. All it should say is that the service is already running.
What kind of errors are you having in the event log? What version of Exchange? |
|
|
|
|
|
#8 |
|
Member (11 bit)
|
Code:
@ECHO OFF FOR /F %%F IN (C:\PROCS.TXT) DO ( SET PROC=%%F CALL :PROCESS ) GOTO :EOF :PROCESS PSLIST | FIND /I "%PROC%" > NUL IF ERRORLEVEL 1 ( ECHO Service is not running! Echo Starting Service Now! net start "Your Service" ) http://www.sysinternals.com/ntw2k/freeware/pslist.shtml make a file called PROCS.TXT with the service you want to check if it exits... Im having a little bit of trouble starting the process but im sure someone here can help.
__________________
Computer: 486 Ram: 8 MB CD Rom: None OS: Windows 3.1 |
|
|
|
|
|
#9 |
|
Resident Slacker
Join Date: Dec 2001
Location: Suisun City, California (i know, where the hell is that?!?!?)
Posts: 2,620
|
ok, i have it setup. hopefully when i come in tomorrow, the information store is running.
it's exchange 2000. here's what gets logged: Event Type: Error Event Source: Service Control Manager Event Category: None Event ID: 7031 Date: 07/21/2004 Time: 9:44:45 AM User: N/A Computer: Exchange Description: The Microsoft Exchange Information Store service terminated unexpectedly. It has done this 1 time(s). The following corrective action will be taken in 0 milliseconds: No action. informative, huh? a search of the ms knowledge base says i need the post sp3 rollup, which when installed on my computer, corrupts store.exe so it won't start at all. i've tried redownloading the patch to no avail. |
|
|
|
|
|
#10 |
|
Professional gadfly
|
If you go to the Service Manager and check on the properties for the service, on the Recovery tab, do you have it set to restart automatically if it fails?
|
|
|
|
|
|
#11 |
|
Staff
Premium Member
Join Date: Jul 1999
Location: Arlington, TN
Posts: 5,538
|
What AV program are you running?
|
|
|
|
|
|
#12 |
|
Resident Slacker
Join Date: Dec 2001
Location: Suisun City, California (i know, where the hell is that?!?!?)
Posts: 2,620
|
yes, i have it setup like that, but unless i manually start it, it won't start. it doesn't give any failure error in the logs, it just won't start. i'm hoping the batch file helps, but my gut is telling me it won't.
i'm running norton antivirus corporate edition server on this particular machine. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|