executing .BAT file?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

executing .BAT file?

Andi Thomas
I'm embarrassed to be asking, but I just can't figure it out.
I need to call an executable with command line style parameters, preferable
as a blocked call.

eg: doSomething.exe -a -b -c

TIA
- Andi


Reply | Threaded
Open this post in threaded view
|

Re: executing .BAT file?

Bill Schwab
Andi,

> I'm embarrassed to be asking, but I just can't figure it out.
> I need to call an executable with command line style parameters,
preferable
> as a blocked call.
>
> eg: doSomething.exe -a -b -c

My first thought on this is KernelLibrary>>winExec:uCmdShow:, but, there
might be a better way.  Even if it is the preferred approach, you will
probably have problems with the blocking part.  First,  #winExec:uCmdShow:
overlaps the call, so it runs on a separate OS thread to avoid blocking the
entire image (something that you want to happen).  You could define a
#blockingWinExec:uCmdShow: to do the same thing but not overlapped.
However, (I think) you will find that you'll still end up with a separate
process running independently of your image, so it won't block????

Do you have control over the thing you are running?  If so, you might be
able to arrange for it to signal a Win32 event or semaphore (I forget the
precise terminology) when it's complete, and have a Dolphin thread wait on
that same event.  IIRC, I had that working once.  Another solution would be
COM connection points, and there's always sockets though I doubt that's
something you'd want to use in this situation.

Have a good one,

Bill

--
Wilhelm K. Schwab, Ph.D.
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: executing .BAT file?

Chris Uppal-3
In reply to this post by Andi Thomas
Andi Thomas wrote:

> I need to call an executable with command line style parameters,
preferable
> as a blocked call.

I haven't tried it myself, but I think CRTLibrary>>_spawnvp:cmdname:argv:
should do what you are looking for.

> - Andi

    -- chris


Reply | Threaded
Open this post in threaded view
|

Re: executing .BAT file?

Ian Bartholomew-4
In reply to this post by Bill Schwab
Andi/Bill

> My first thought on this is KernelLibrary>>winExec:uCmdShow:, but, there
> might be a better way.

How about ShellLibrary>>shellOpen: and family?. Not sure if they are better
but I _think_ they might block until the command terminates - not at all
sure though.

Used as in -

ShellLibrary default shellOpen: 'the bat file path and name'

Ian


Reply | Threaded
Open this post in threaded view
|

Re: executing .BAT file?

Ingo Blank-6
In reply to this post by Andi Thomas
"Andi Thomas" <[hidden email]> schrieb im Newsbeitrag
news:9nssvm$9fmhj$[hidden email]...
> I'm embarrassed to be asking, but I just can't figure it out.
> I need to call an executable with command line style parameters,
preferable
> as a blocked call.
>
> eg: doSomething.exe -a -b -c
>
> TIA
> - Andi

Andi,

the approach to achieve a blocked OS call is using a pair of Win API calls.

1.    CreateProcess
2.    WaitForSingleObject

Win signals a Semaphore, when the called process has finished.
For more information you should search the MSDN knowledgebase.
I definitely know, that there are articles about this issue (with sample
code).

HTH

-Ingo