Go Back   PCMech Forums > Windows Support > Windows Legacy Support (XP and earlier)

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 07-27-2004, 02:12 PM   #1
Resident Slacker
 
homer15's Avatar
 
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
homer15 is offline   Reply With Quote
Old 07-27-2004, 02:36 PM   #2
Barefoot on the Moon!
Staff
Premium Member
 
Force Flow's Avatar
 
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.
Force Flow is offline   Reply With Quote
Old 07-27-2004, 02:53 PM   #3
Resident Slacker
 
homer15's Avatar
 
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.
homer15 is offline   Reply With Quote
Old 07-27-2004, 03:05 PM   #4
Staff
Premium Member
 
mairving's Avatar
 
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
mairving is offline   Reply With Quote
Old 07-27-2004, 03:08 PM   #5
Professional gadfly
 
doctorgonzo's Avatar
 
Join Date: Jan 2002
Location: Minneapolis, MN
Posts: 6,364
Send a message via MSN to doctorgonzo
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.
doctorgonzo is offline   Reply With Quote
Old 07-27-2004, 03:08 PM   #6
Resident Slacker
 
homer15's Avatar
 
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?
homer15 is offline   Reply With Quote
Old 07-27-2004, 03:19 PM   #7
Staff
Premium Member
 
mairving's Avatar
 
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?
mairving is offline   Reply With Quote
Old 07-27-2004, 03:28 PM   #8
Member (11 bit)
 
Doobie's Avatar
 
Join Date: Jul 2002
Location: Mexico
Posts: 1,049
Send a message via AIM to Doobie Send a message via Yahoo to Doobie
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"
)
download PList and add it to the folder where you bat is in.
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
Doobie is offline   Reply With Quote
Old 07-27-2004, 03:32 PM   #9
Resident Slacker
 
homer15's Avatar
 
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.
homer15 is offline   Reply With Quote
Old 07-27-2004, 03:43 PM   #10
Professional gadfly
 
doctorgonzo's Avatar
 
Join Date: Jan 2002
Location: Minneapolis, MN
Posts: 6,364
Send a message via MSN to doctorgonzo
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?
doctorgonzo is offline   Reply With Quote
Old 07-27-2004, 04:19 PM   #11
Staff
Premium Member
 
mairving's Avatar
 
Join Date: Jul 1999
Location: Arlington, TN
Posts: 5,538
What AV program are you running?
mairving is offline   Reply With Quote
Old 07-27-2004, 04:22 PM   #12
Resident Slacker
 
homer15's Avatar
 
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.
homer15 is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 12:32 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2