Board index » delphi » Eexecute a bat file

Eexecute a bat file

Hi
        Since I didnt find any function to copy files under delphi I
remebered to put the instructions on a .BAT file and run it under Delphi.
        -Do you know how to execute the .BAT file under DELPHI?
        -How can I obtain the current WINDOWS directory?
        -How can I set the charcase of a stringgrid to uppercase?
        PLEASE ANSWER ME IF YOU KNOW THE SOLUTION OF ANY OF THESE PROBLEMS.

 Thank you very much, Andre Brandao, CT2GGD

        *****************************************
        *                                       *
        *  Andre Brandao                        *
        *  E-mail: l42...@alfa.ist.utl.pt       *
        *      or  ac...@camoes.rnl.ist.utl.pt  *
        *                                       *
        *****************************************

 

Re:Eexecute a bat file


Quote
>>        -Do you know how to execute the .BAT file under DELPHI?

        presuming your going to run  the app from within windows, search the
delphi help on WINEXEC....

Quote
>>        How can I obtain the current WINDOWS directory?

        take a look in the delphi help on the topic GETWINDOWSDIRECTORY....

also, to copy a file in delphi 2, take a look at the API routine COPYFILE
in the help...

Andre Brandao <l42...@alfa.ist.utl.pt> wrote in article
<Pine.OSF.3.91.970225170224.28173B-100...@alfa.ist.utl.pt>...

Quote
> Hi
>    Since I didnt find any function to copy files under delphi I
> remebered to put the instructions on a .BAT file and run it under Delphi.
>    -Do you know how to execute the .BAT file under DELPHI?
>    -How can I obtain the current WINDOWS directory?
>    -How can I set the charcase of a stringgrid to uppercase?
>    PLEASE ANSWER ME IF YOU KNOW THE SOLUTION OF ANY OF THESE PROBLEMS.

>  Thank you very much, Andre Brandao, CT2GGD

>         *****************************************
>         *                                       *
>         *  Andre Brandao                        *
>         *  E-mail: l42...@alfa.ist.utl.pt       *
>         *      or  ac...@camoes.rnl.ist.utl.pt  *
>         *                                       *
>         *****************************************

Re:Eexecute a bat file


Quote
Andre Brandao wrote:

> Hi
>         Since I didnt find any function to copy files under delphi I
> remebered to put the instructions on a .BAT file and run it under Delphi.
>         -Do you know how to execute the .BAT file under DELPHI?
>         -How can I obtain the current WINDOWS directory?
>         -How can I set the charcase of a stringgrid to uppercase?
>         PLEASE ANSWER ME IF YOU KNOW THE SOLUTION OF ANY OF THESE PROBLEMS.

>  Thank you very much, Andre Brandao, CT2GGD

>         *****************************************
>         *                                       *
>         *  Andre Brandao                        *
>         *  E-mail: l42...@alfa.ist.utl.pt       *
>         *      or  ac...@camoes.rnl.ist.utl.pt  *
>         *                                       *
>         *****************************************

to find windows directory:
var
windowsdir:string[60];
begin
GetWindowsDirectory(@WindowsDir[1], SizeOf(WindowsDir) - 1);
WindowsDir[0] := Chr(StrLen(@WindowsDir[1]));
edit1.text:=windowsdir;
end;
If you want to copy a file look for fmxutils.pas which contains copyfile
Ken
K...@netcomuk.co.uk

Re:Eexecute a bat file


Quote
>    Since I didnt find any function to copy files under delphi I
> remebered to put the instructions on a .BAT file and run it under Delphi.
>    -Do you know how to execute the .BAT file under DELPHI?
>    -How can I obtain the current WINDOWS directory?
>    -How can I set the charcase of a stringgrid to uppercase?
>    PLEASE ANSWER ME IF YOU KNOW THE SOLUTION OF ANY OF THESE PROBLEMS.

Use WinExec command, check the format from Help.
But do you know how to sleep in delphi ??, There is not any command like
pascal sleep().

Sakari Heino

Re:Eexecute a bat file


Hi,
Sakari Heino <sa...@sci.fi> wrote in article
<01bc2541$ed071ea0$0e024ac3@phsahe>...

Quote
> >       Since I didnt find any function to copy files under delphi I
> > remebered to put the instructions on a .BAT file and run it under

Delphi.
There is a FileCopy command.

Quote
> >       -Do you know how to execute the .BAT file under DELPHI?
> Use WinExec command, check the format from Help.

I prefer the SHELLEXECUTE Command :
RetHandle := shellExecute(HndWnd, 'open', @cmdline[1], @Params[1],
           @WorkDir[1], SW_SHOWNORMAL); (*SW_SHOWMINIMISED*)
   Application.ProcessMessages;

Quote
> >       -How can I obtain the current WINDOWS directory?

var     tempBuff: string;
        P:            PChar;

     GetSystemDirectory(P, 254); (*usually c:\windows\system  or
c:\winnt\system*)
     tempBuff := StrPas(P);
     GetWindowsDirectory(P, 254); (*usually c:\windows\system  *)
     gWinDir := StrPas(P);
(*then you can check for a file:*)
     if NOT FileExists(tempBuff + '\' + IniName) then
        etc

Quote
> But do you know how to sleep in delphi ??, There is not any command like
> pascal sleep().

Perhaps this yields?    Application.ProcessMessages;

Regards
Iris

Other Threads