Re: Problem when executing application from batch file
- From: "Jack" <replyto@newsgroup>
- Date: Wed, 5 Oct 2005 23:36:04 -0400
I like that /b extra parameter as indication of the batch execution too.
It will allow me to provide special code for batch file execution only,
leaving the original part of the code almost intact.
Present code flow is as following.
In Main routine code checks for PrevInstance.
If true then
1. it reads registry to get the handle of PrevInstance
2. it uses SendMessage() to send parameter
for execution if the app is idling
or for storing it in the buffer for the later execution (FIFO) after
current execution will be over.
Hope it is clear,
Jack
"J French" <erewhon@xxxxxxxxxx> wrote in message
news:4343ad19.270964873@xxxxxxxxxxxxxxxxxxxxxxx
> 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
>
>
>
>
.
- References:
- Problem when executing application from batch file
- From: Jack
- Re: Problem when executing application from batch file
- From: J French
- Problem when executing application from batch file
- Prev by Date: Re: Lowlevel DDE, Insertable, Verb, ProgID, InProcHandler32, LocalServer32, CLSID, AppID, and AuxUserType
- Next by Date: Re: Farewell VB6 -- Hello VB.NET 2005
- Previous by thread: Re: Problem when executing application from batch file
- Next by thread: DB Processing Question
- Index(es):
Relevant Pages
|
Loading