Running external programs with ShellAPI

Running external programs with ShellAPI

Post by Geral » Fri, 25 Jan 2002 17:36:51



Hi I need to run a batch file from within my application
this is how I do it

uses ShellApi;

...
begin
..
        ShellExecute(Handle, 'open', '.\update.bat', nil, nil,
SW_SHOWNORMAL);
end;

It works fine. However the window does not automatically close although it
has been terminated. I have to manually click on the x each time and this is
quite irritating because the file is executed every few minutes.
Any help would be greatly appreciated. Thanks

 
 
 

Running external programs with ShellAPI

Post by Maarten Wiltin » Fri, 25 Jan 2002 18:13:43



Quote:>Hi I need to run a batch file from within my application
>this is how I do it

>uses ShellApi;

>...
>begin
>..
>        ShellExecute(Handle, 'open', '.\update.bat', nil, nil,
>SW_SHOWNORMAL);
>end;

>It works fine. However the window does not automatically close although it
>has been terminated. I have to manually click on the x each time and this
is
>quite irritating because the file is executed every few minutes.

You can check the "close on finish" box in the properties
(may not be called exactly that, but similar). This would
need to done only once, but potentially on all installations.

IIRC, %windir%/_default.pif specifies the default settings
for DOS boxes. But even so, you may not want this to be the
default. All in all, it's a nuisance alright.

(Perhaps running 'command.com /c update.bat' would work
better. But it's still a kludge.)

Groetjes,
Maarten Wiltink

 
 
 

Running external programs with ShellAPI

Post by Evgeny V. Levasho » Fri, 25 Jan 2002 18:39:12



Quote:> Hi I need to run a batch file from within my application
> this is how I do it

> uses ShellApi;

> ...
> begin
> ..
>         ShellExecute(Handle, 'open', '.\update.bat', nil, nil,
> SW_SHOWNORMAL);
> end;

> It works fine. However the window does not automatically close although it
> has been terminated. I have to manually click on the x each time and this
is
> quite irritating because the file is executed every few minutes.
> Any help would be greatly appreciated. Thanks

1. It seems you run MSDOS programms. Make a pif files for all of them with
checked combo "automatically close when done" in it.
With ShellExecute you need to start these pifs.

2. Or run your programms with command "c:\command.com
<your_msdos_application> /c"

I have used the same things under WIN 95/98, and I don't know what a
behaviour you'll get under NT.

Eugene.

 
 
 

Running external programs with ShellAPI

Post by Maarten Wiltin » Fri, 25 Jan 2002 20:14:30




>> Hi I need to run a batch file from within my application
>> this is how I do it

>> uses ShellApi;

>> ...
>> begin
>> ..
>>         ShellExecute(Handle, 'open', '.\update.bat', nil, nil,
>> SW_SHOWNORMAL);
>> end;

>> It works fine. However the window does not automatically close although
it
>> has been terminated. I have to manually click on the x each time and
this
>is
>> quite irritating because the file is executed every few minutes.
>> Any help would be greatly appreciated. Thanks

>1. It seems you run MSDOS programms. Make a pif files for all of them with
>checked combo "automatically close when done" in it.
>With ShellExecute you need to start these pifs.

>2. Or run your programms with command "c:\command.com
><your_msdos_application> /c"

>I have used the same things under WIN 95/98, and I don't know what a
>behaviour you'll get under NT.

I can answer that, for the same reason I wasn't sure about
the exact caption of that checkbox. NT ruins[0] dos boxes
as console applications, and closes them when done.

Groetjes,
Maarten Wiltink

[0] That's a typo! I swear that was a typo!

 
 
 

Running external programs with ShellAPI

Post by Evgeny V. Levasho » Sat, 26 Jan 2002 15:51:39



> > >1. It seems you run MSDOS programms. Make a pif files for all of them
with
> >checked combo "automatically close when done" in it.
> >With ShellExecute you need to start these pifs.

> >2. Or run your programms with command "c:\command.com
> ><your_msdos_application> /c"

> >I have used the same things under WIN 95/98, and I don't know what a
> >behaviour you'll get under NT.

> I can answer that, for the same reason I wasn't sure about
> the exact caption of that checkbox. NT ruins[0] dos boxes
> as console applications, and closes them when done.

About caption of the check box -- I am using Russian version of Windows :)

I was not sure about NT behaviour in the case when programm has been started
using "command.com". I just checked. In this case it's necessary to run
external msdos programme like with the following:
"c:\winnt\system32\command.com /c <your_msdos_application>".

Eugene.

 
 
 

Running external programs with ShellAPI

Post by J Fren » Sat, 26 Jan 2002 20:53:45


On Fri, 25 Jan 2002 09:51:39 +0300, "Evgeny V. Levashov"


>I was not sure about NT behaviour in the case when programm has been started
>using "command.com". I just checked. In this case it's necessary to run
>external msdos programme like with the following:
>"c:\winnt\system32\command.com /c <your_msdos_application>".

>Eugene.

Or more sensibly:
     GetEnvirormentVariable( 'comspec',  S[1], Length(S))
 
 
 

Running external programs with ShellAPI

Post by Guent » Mon, 28 Jan 2002 08:36:26


If you do not  need to see the batch-window:
use SW_HIDE instead of SW_SHOWNORMAL

Guenth

 
 
 

1. external programs run on insert?

I would like to have a trigger on insert run a script outside the database.

I see provisions for sandboxed perl, python and a external c lib. I just
want to fire off a simple script in the file system, am I missing
something?

I'm very comfortable with the security implications of this.

Adam of the net domain devtty

2. Please help

3. Filemaker pro 3 and running an external program

4. Anybody knows Arcview here??

5. run external program

6. DB compare

7. Running external programs fro Paradox

8. Trigger runs an external program?

9. Running external programs

10. Running External (UNIX programs) from PLSQL

11. Running external program in VFP

12. Running external programs from within dBASE3+ application?