How do I respond yes in a batch file for a service restart with dependencies

  • Thread starter Deleted member 19858
  • Start date
D

Deleted member 19858

Guest
I want to create a batch script that will be used for the Exchange Information Store to say if the service stops, start the service, and restart the MTA stacks. The script I have so far says the following, but it isn't responding to the question correctly.

Code:
@echo off
NET START "Microsoft Exchange Information Store"
echo y|NET STOP "Microsoft Exchange MTA Stacks"
NET START "Microsoft Exchange MTA Stacks"
NET START "LFExGateway"

When I run this script it returns the following:

Code:
C:\Documents and Settings\remoteadmin\Desktop>XMediusFAX.bat
The following services are dependent on the Microsoft Exchange MTA Stacks service.
Stopping the Microsoft Exchange MTA Stacks service will also stop these services.
 
   LFExGateway
 
Do you want to continue this operation? (Y/N) [N]:
No valid response was provided.
The requested service has already been started.
 
More help is available by typing NET HELPMSG 2182.
 
Do you want to continue this operation? (Y/N) [N]:

i think you just replace [N] with y or /yes
 
why not just stop the LFXeGateway first?

Try:
Code:
@echo off
NET START "Microsoft Exchange Information Store"
echo "Stopping LFExGateway"
NET STOP "LFExGateawy"
echo y|NET STOP "Microsoft Exchange MTA Stacks"
NET START "LFExGateway"
NET START "Microsoft Exchange MTA Stacks"

I'm sure there's a way to tell it to default to "yes"... this way should work just as well though.
 
Stopping the LFExGateway first did the trick, dunno why I didn't think of that, thanks.
 
can I ask why you're using a batch file for this instead of built in service recovery actions? I'm pretty sure that gracefully handles dependencies.
 
You can also redirect a file into a command. i.e. make a file called y.txt that has a Y and Carriage return then it would look something like this.


Code:
@echo off
NET START "Microsoft Exchange Information Store"
NET STOP "Microsoft Exchange MTA Stacks" < c:\y.txt
NET START "Microsoft Exchange MTA Stacks"
NET START "LFExGateway"
 
Back
Top