Board index » delphi » Run ms-dos command in Pascal program

Run ms-dos command in Pascal program

Can anyone tel me how can i execute a ms-dos command in a Pascal program.

Tanks in advanced.

Jo?o Pedro
j....@usa.net

 

Re:Run ms-dos command in Pascal program


Hi Jo#o,

25 November 1998, 12:35; Jo#o Pedro wrote a message. This requires reply!

 JP> Can anyone tel me how can i execute a ms-dos command in a Pascal
 JP> program.
 JP> Tanks in advanced.

Look at Exec :)

Example:

Program Test;

Uses Dos,Crt;

Var Cmd,Line:String;

Begin
    Cmd := 'TREE.EXE';
    Line := '/F';
    Exec (Cmd,Line);
End.

It's as easy as that :))

Goodbye and see ya later Jo#o......
Greets from Rene.
e-mail: Rene.Bak...@rapmet.iwg.nl

... Waar ben jij geweest? MARS?

Re:Run ms-dos command in Pascal program


Quote
>  JP> Can anyone tel me how can i execute a ms-dos command in a Pascal
>  JP> program.
> Program Test;
> Uses Dos,Crt;
> Var Cmd,Line:String;
> Begin
>     Cmd := 'TREE.EXE';
>     Line := '/F';
>     Exec (Cmd,Line);
> End.
> It's as easy as that :))

Not exactly as easy. To execute any dos command, exec() command.com with
'/C <command>' as command line. Don't forget to limit the memory. And
don't confuse the three 'command's :-)

Thats FAQ #9 by the way.

Daniel

--
Daniel Fischer
d...@freudenstadt.net

Other Threads