Re: Problem when executing application from batch file
- From: erewhon@xxxxxxxxxx (J French)
- Date: Wed, 5 Oct 2005 11:16:13 +0000 (UTC)
On Tue, 4 Oct 2005 18:01:22 -0400, "Jack" <replyto@newsgroup> wrote:
>Hello,
> I have that strange problem. My application can accept commands
>from command prompt and if there are more commands it will store commands in
>buffer and execute one by one
>Everything is fine and dandy when application is up and running and after
>that the comands (multi-commands from batch file) are sent.
>However, when application is not running and the batch file is used with
>multi-commands, then the first command will invoke the application and the
>batch execution will stop (pause). When application is closed then
>automatically, the second batch line will invoke the application again.
>That strange behaviour will be repeated until all commands will be sent from
>batch file.
Having followed this thread, I think I've a fair idea of what you want
to do.
It is news to me that the default behaviour of a Batch file is to wait
until the /Windows/ App is closed
- and that does not happen on my Win95 setup (just checked)
But it does happen on my XP Pro setup - amazing !
If you write a tiny stripped down loader for your App and use:
MiniLoader /365544776
Then MiniLoader can launch your real App with the Commandline as
usual, it can wait until your app is responding, then terminate to
allow the next line of the batch file to be executed.
Next time MiniLoader runs, it will find your real App is already
running so it can pass on the info and terminate immediately
Making your real App into an AX EXE would make things much simpler for
you.
Also I would not rely too much on App.PrevInstance, use a Mutex
instead - that can be used by both your App and MiniLoader.exe
Also, if you use RegisterWindowMessage you can get a guaranteed unique
message ID that can be used with WM_BROADCAST to identify an already
running App - if any
The simplest method is to use an AX EXE, just make its exposed Class
MultiUse (default) and keep it alive by giving it a Form
Another method would be to load the real App directly from the batch
file, but give it an extra parameter /b[atch] which makes it launch a
clone of itself, pass on the Command line ( excluding /b ) and then
terminate to allow the batch file to continue
That might be the most 'granular' method, as you just land up with one
EXE, and loading 'clones' will be trivial as your check for /b or
another instance will take place in Sub Main()
On balance I would go for the last option.
BTW I would be interested to hear how you are identifying the existing
instance and passing on the Command line
- I have that wrapped in a Delphi DLL using RegisterWindowMessage and
WM_COPYDATA
HTH
.
- Follow-Ups:
- References:
- Prev by Date: Re: POLYTEXTOUT problems..( including declarations )
- Next by Date: Re: a question about moving pictures
- Previous by thread: Re: Problem when executing application from batch file
- Next by thread: Re: Problem when executing application from batch file
- Index(es):
Relevant Pages
|