Board index » delphi » Executing DOS batch files (or any other program files) and deleting files with PASCAL

Executing DOS batch files (or any other program files) and deleting files with PASCAL

Is it possible to just use the PASCAL EXEC DOS function to execute DOS
programs and delete files?

Please help!  I've been trying an answer to this for nearly 2 years!

Thanks.

--
Rayearth

 

Re:Executing DOS batch files (or any other program files) and deleting files with PASCAL


Quote
Rayearth wrote:

> Is it possible to just use the PASCAL EXEC DOS function to execute DOS
> programs and delete files?
> Please help!  I've been trying an answer to this for nearly 2 years!

2 years? That is too long. :-)

Look for the Exec command, then study COMMAND.COM and
GetEnv('COMSPEC'), in addition look for SwapVectors and
{$M sss, nnn, xxx}

in your F1-Help. Assumed Turbo Pascal or similar.

There is an article in Timo's FAQ, you find it in the
FAQ - chapter of TP-links
http://www.geocities.com/SiliconValley/2926/tp.html
new: framed version:
http://www.geocities.com/SiliconValley/2926/tpf.html

Franz Glaser

Re:Executing DOS batch files (or any other program files) and deleting files with PASCAL


JRS:  In article <72ihlo$8s...@imsp009a.netvigator.com> of Sat, 14 Nov
1998 08:07:33 in news:comp.lang.pascal.misc, Rayearth

Quote
<weiji...@netvigator.com> wrote:
>Is it possible to just use the PASCAL EXEC DOS function to execute DOS
>programs and delete files?

>Please help!  I've been trying an answer to this for nearly 2 years!

This is c.l.p.misc, and it is difficult to answer such a specific
question when all we can safely deduce is that you have DOS.

If you had asked in the group for Turbo Pascal, c.l.p.borland, then we
can safely answer "Yes".

The answer there is to use command.com - see for example in
Web <URL: http://www.merlyn.demon.co.uk/pas-extn.htm>
  SwapVectors ;
  Exec(GetEnv('COMSPEC'), ' /C ' + CommandString) ;
  SwapVectors ;

or of course in the essential FAQ by Timo Salmi, item #9, also #104,
#120, #146.

Don't forget the {$M...}.

Web <URL: http://www.merlyn.demon.co.uk/programs/hunt.pas> includes what
you would want, too.

--
John Stockton, Surrey, UK.    j...@merlyn.demon.co.uk    Turnpike v4.00    MIME.
  Web <URL: http://www.merlyn.demon.co.uk/> - TP/BP/&c. FAQqish topics & links.
  Timo's TurboPascal <A HREF="ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip">FAQ</A>.
  <A HREF="http://www.merlyn.demon.co.uk/clpb-faq.txt">Mini-FAQ</A> of c.l.p.b.

Re:Executing DOS batch files (or any other program files) and deleting files with PASCAL


Quote
Rayearth wrote:
> Is it possible to just use the PASCAL EXEC DOS function to execute DOS
> programs and delete files?

> Please help!  I've been trying an answer to this for nearly 2 years!

> Thanks.

> --
> Rayearth

You haven't exactly been pondering a very complicated question for 2
years.
I'm not sure I understand your question, but you can execute command.com
like this to execute a dos command  "command.com /c del *.* "
Though why would you want to?  I believe off hand this works to
 delete a file. (Look in pascal's help on the erase and exec commands)

  Var
      f: file;

   Begin
        assign(f,'ANYFILE.ZZZ');
        erase(f);
   end;

Other Threads