Re: Problem when executing application from batch file



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
>
>
>
>


.



Relevant Pages

  • Re: Batch file and MFC (Properly Terminating Application)
    ... This is continuation of previous post listed under Subject: Batch file ... EVER write something as ridiculous as comparing a BOOL to TRUE or FALSE!!!! ... execution, and therefore presuming synchronous execution is completely wrong. ... TraceEvent * Explanation ...
    (microsoft.public.vc.mfc)
  • Re: Problem when executing application from batch file
    ... there are multiple lines in the batch file. ... can contain different params and different numbers of commands. ... This works fine when my app is running and a batch file executed. ... Batch execution stops after first line. ...
    (microsoft.public.vb.general.discussion)
  • Re: Problem when executing application from batch file
    ... > Batch execution stops after first line. ... any commands after "batch2" appearance in batch1 are not executed. ... Inside a batch file, it will wait until the app exists. ...
    (microsoft.public.vb.general.discussion)
  • Re: Schedule Batch File-How to?
    ... Panel> Scheduled Task etc. and the batch file name was used as the program ... The destination locations were checked to insure execution had taken place ... Windows command that you are using within the batch file. ... according to the schedule you selected. ...
    (microsoft.public.windowsxp.general)
  • Re: Issue in execution of batch files Windows XP Pro
    ... folder just created ... What we noticed is that bigger is the file batch file (just placing more ... Just changing the extension from .bat to .cmd the execution become faster. ... Since running your program as a .cmd file ...
    (microsoft.public.windowsxp.general)

Loading