From: "Zorallin"
Subject: Re: BATCH FILES OPENING
Date: 23 Feb 2000 00:00:00 GMT
Message-ID: <88vvuu$65b2@bornews.borland.com>
References: <88vtm2$64u3@bornews.borland.com>
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211
Organization: Another Netscape Collabra Server User
X-MSMail-Priority: Normal
Newsgroups: borland.public.delphi.winapi
Using the GetEnvironmentVariable(...) API call get the
"COMSPEC" environment variable (path to the command
processor and launch that with WinExec(...) as something
like;
(* set up variables, etc... *)
GetEnvironmentVariable( 'ComSpec', PChar(strCmdProcessor), 255 );
strCmdProcessor := strCmdProcessor + ' /C yourfile.bat';
WinExec( strCmdProcessor, SW_SHOWNORMAL );
(* continue on.... *)
you can also pass extra parameters to be processed by your
batch file if you format the string with them before passing it to
WinExec(...). NOTE: WinExec(...) will launch an asynchronous
completely separate application which will run to conclusion with
or without your program's presence. If you want more control
than that look at CreateProcessEx(..) or one of the other thread
oriented lanuching schemes.
HTH
-------------------------------------------------------------------
"If you think you know the answer,
then you don't understand the question !"
-------------------------------------------------------------------
Gerald Morris wrote in message
news:88vtm2$64u3@bornews.borland.com...
> Is there a way to open and execute a DOS batch file with Delphi?
>
> (I want to run gbak to back up my Interbase database at night).
>
> Gerald Morris