Link to home
Start Free TrialLog in
Avatar of truth_talker
truth_talker

asked on

Answer yes to question in Batch File

I'm trying to write a batch file to stop a software package for backups.

I can stop the actual service using "net stop", but the software company recommends to use their stop command.  The problem is it asks "do you want to stop the product", but I can't figure out in a .bat file how to make this happen.

The vendor says to use their stop_program.exe because it stops the different services in order and they have a startup.exe file also.

Is there a way to do this in a .bat file, or a utility out there than can do this?

I found one article that said to use "echo y | stopcommand.exe" but that does not work.

Thanks,

Patrick
ASKER CERTIFIED SOLUTION
Avatar of rhinoceros
rhinoceros

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Greetings, truth_talker.

Using Notepad create a text file (i.e. something like Yes.txt) and put the letter Y into it.  Save the file into the folder containing your batch file.  Edit your batch file and add the following to any line that causes the prompt

    < Yes.txt

For example, if this command

    net stop MyService

causes the "do you want to stop the product prompt", then change that command line to read

    net stop MyService < Yes.txt

I've used this approach for a long time to answer the "are you sure" question about overwriting files, etc.  It works fine.  I'm not sure it'll work with this third-party software, but it's worth a try.

Cheers!
BlueDevilFan, that will do the same as echo Y| in all cases I have used it for (used to do the <y.txt way before echo Y|).

Either way will not work with most GUI apps IMO.

Steve
Steve,

Thanks for the tip, I wasn't aware of that.  I've seen the <y.txt quite a bit, but hadn't seen the echo Y| approach.
split dragon-it & rhinoceros