?
Solved

Answer yes to question in Batch File

Posted on 2006-11-15
9
Medium Priority
?
957 Views
Last Modified: 2008-01-16
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
0
Comment
Question by:truth_talker
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
9 Comments
 
LVL 13

Accepted Solution

by:
rhinoceros earned 1000 total points
ID: 17953765
1.
>I found one article that said to use "echo y | stopcommand.exe" but that does not work.

I believe it is not common DOS command execute file (maybe GUI file), so why "echo y | ..." dose not work.

2.
> 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.

In case, you can ask the vendor what is the order of all services, and then run the batch file to run "net stop" in order

e.g. stop.bat
net stop service1
net stop service2
net stop service3
etc.

e.g. start.bat
net start service1
net start service2
net start service3

3. Sometimes some programs will need to run something during service starting, it must have enough time gap between different services startup or stop. Therefore, they request you to use their provided program.

So you can try to use vbscript to run
e.g. start.vbs

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run("net start service1")
WScript.Sleep 10000 'sleep for 10 seconds
WshShell.Run("net start service2")
WScript.Sleep 10000 'sleep for 10 seconds
... (more)

e.g. stop.vbs
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run("net stop service1")
WScript.Sleep 10000 'sleep for 10 seconds
WshShell.Run("net stop service2")
WScript.Sleep 10000 'sleep for 10 seconds
... (more)


If true, please ask your vendor how many time (sleep) you will need to set  ?


I hope it can help .
0
 
LVL 43

Assisted Solution

by:Steve Knight
Steve Knight earned 1000 total points
ID: 17954777
Is this a GUI app. or text mode waiting for Yes at command prompt?  It could be as simple as it is waiting for an upper case Y or somethign else, i.e.

echo Y|stop_programexe

What exactly does it do / look like - a dialog box?

For full control over it I suggest AutoIt.  You can write a two-line simple script which will wait for a window with a particualr title to come up and then send certain keys.  Syntax is something like this (has changed recently and don't have it installed here:)

WinWaitActvive "WindowTitle"
Send "y{Return}"

or whatever

http://www.autoitscript.com/autoit3/

Steve
0
 
LVL 76

Expert Comment

by:David Lee
ID: 17954788
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!
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 43

Expert Comment

by:Steve Knight
ID: 17954880
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
0
 
LVL 76

Expert Comment

by:David Lee
ID: 17954985
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.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 18386296
split dragon-it & rhinoceros
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I guess it is not common knowledge to most Wintel engineers/administrators: If you have an SNMP-based monitoring system in your environment (and it's common to have SNMP or Syslog) it's reasonably easy to enable monitoring of the Windows Event logs,…
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question