Solved

Answer yes to question in Batch File

Posted on 2006-11-15
9
939 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
  • 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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

[Webinar] Disaster Recovery and Cloud Management

Learn from Unigma and CloudBerry industry veterans which providers are best for certain use cases and how to lower cloud costs, how to grow your Managed Services practice in IaaS clouds, and how to utilize public cloud for Disaster Recovery

Question has a verified solution.

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

by Batuhan Cetin Within the dynamic life of an IT administrator, we hold many information in our minds like user names, passwords, IDs, phone numbers, incomes, service tags, bills and the order from our wives to buy milk when coming back to home.…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now