Solved

Answer yes to question in Batch File

Posted on 2006-11-15
9
952 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 250 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 250 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
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

 
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

Technology Partners: 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!

Question has a verified solution.

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

This may not be a text book method to resolve VSS backup issues but it seemed to have worked on few of the Windows 2003 servers we had issues while performing a Volume Shadow Copy backup. If you have issues while performing a shadow copy backup usin…
Numerous times I have been asked this questions that what is it that makes my machine log on so slow, there have been cases where computers took 23 minute exactly after taking password and getting to the desktop. Interesting thing was the fact th…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

691 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