Google Answers Logo
View Question
 
Q: Writing Win32 .bat files: How to have .bat end w/ called prog still running ( Answered 5 out of 5 stars,   0 Comments )
Question  
Subject: Writing Win32 .bat files: How to have .bat end w/ called prog still running
Category: Computers > Programming
Asked by: donphiltrodt-ga
List Price: $9.00
Posted: 14 Mar 2004 11:21 PST
Expires: 13 Apr 2004 12:21 PDT
Question ID: 316644
I've written a three-line batch file...

(delete some files)
(delete some other files)
(start FancyProgram)

Problem: Batch file waits for FancyProgram to end before terminating.

Solution: Tell me how to call a program from a batch file, then have
the batch batch proceed whether or not the program is still running. 
(In this case, 'proceeding' to the end and then exiting.)


Also, if you happen to know of some good tutorials for batch writing,
please include them.  (But don't spend a bunch of extra time.)

Request for Question Clarification by aht-ga on 14 Mar 2004 16:19 PST
donpniltrodt-ga:

You mention that you are working with batch files and Win32 programs.
Can you clarify the exact operating system that you are working in?
There is a simple way to do what you are looking for, that works in
Win98, W2K, and XP without any problems. If you can confirm for me the
operating system you are using, I can provide you with an Answer that
does what you are looking for, along with some links to useful online
resources for batch files.

Regards,

aht-ga
Google Answers Researcher
Answer  
Subject: Re: Writing Win32 .bat files: How to have .bat end w/ called prog still running
Answered By: aht-ga on 14 Mar 2004 17:19 PST
Rated:5 out of 5 stars
 
donphiltrodt-ga:

In order to have a batch file call another program, then complete the
rest of its commands before that other program has completed, you have
two options that are supported by all versions of Windows since
Windows 95. The two options are: 1) use the 'start' command in your
batch file directly; 2) create a Windows shortcut (*.lnk) file, and
call that from your batch file.

START COMMAND
-------------

The START command method is the easiest; simply add the command START
in front of the program name in your current batch file, and you're
done. So, if your current Batch File contains the line:

  FancyProgram.exe

you would change it to:

  START FancyProgram.exe

and you're done.

WINDOWS SHORTCUT FILE
---------------------

The second way to accomplish the same thing is to use a Windows
Shortcut File. That way, the Shortcut will get called by the batch
file, start up the intended program in its own session, then return
control of the original command processor session to the batch file so
that it can end.

First, create FancyProgram.lnk by simply creating a Windows shortcut
to FancyProgram.exe in Windows (right-click on FancyProgram.exe in
Windows Explorer, then select 'Create Shortcut'). You can place this
shortcut anywhere you like, but probably best to put it where
FancyProgram.exe itself resides.

Next, edit your batch file so that instead of calling
FancyProgram.exe, you call FancyProgram.lnk instead.

That's all.

when you run the batch file, it will either take over the active
command processor session (if you are calling it from a command
prompt), or start up a command processor session. It will process all
of the commands leading up to the line with FancyProgram.lnk. When it
gets to that line, it will call FancyProgram.lnk, and pass control
over the current, active command processor session to it.
FancyProgram.lnk, in turn, will start up FancyProgram.exe in a new
session. Once it has done this, it will terminate itself, returning
control over the original command processor session to your batch
file. FancyProgram.exe, in the meanwhile, will still be running in its
separate session.

MORE BATCH FILE INFO
--------------------

For further information on how to squeeze more utility out of batch
files in Windows operating systems, check out the following useful
websites:

Rob van der Woude's Scripting Pages (click on 'batch files' on the left-hand menu)
http://www.robvanderwoude.com/index.html

Computing.Net Batch File Help
http://www.computerhope.com/batch.htm 

Ahuka.com DOS Lesson 17:Batch FIle Variables
http://www.ahuka.com/dos/lesson17.html

 - variables are great for designing/using nested batch files, you can
create an entire nested menu system using them.


I hope this helps!

aht-ga
Google Answers Researcher





Search Strategy
---------------

personal knowledge developed since before the days of MS-DOS 3.3

batch files .bat call
://www.google.com/search?q=batch+files+.bat+call
donphiltrodt-ga rated this answer:5 out of 5 stars and gave an additional tip of: $1.00
Thanks.  Just what I needed.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy