Solved

execute dos commands

Posted on 2001-06-07
9
173 Views
Last Modified: 2012-05-04
How can I execute a dos command from Delphi

thanks
0
Comment
Question by:AngelFireMateo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 22

Accepted Solution

by:
Mohammed Nasman earned 50 total points
ID: 6165140
Hello

 you can do that by use WinExcu to open new instance of command.com follow by dos command that u want to use

WinExec('command.com /c dir',sw_ShowNormal);


Best regards
Mohammed Nasman
0
 
LVL 1

Author Comment

by:AngelFireMateo
ID: 6165177
is there another way????
0
 

Expert Comment

by:moorrees
ID: 6165531
Yes there is, this is the dos way ->


//Defines
  char prog[256];
  char *path;
 
//First find the path of the file you want  to execute
   path = searchpath("file.exe");

// create the prog as
   AnsiString command=path;

   int result=spawnlp ( P_NOWAIT,
                        path,
                        path,
                        params,
                        NULL );
  if (result != -1)
  {  Close();
  }
  else
  //something went wrong
}
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 17

Expert Comment

by:inthe
ID: 6165568
depends on what command your trying to do,often theres another way ,like instead of dos copy there copyfile() etc..
what command are you trying to use ?
0
 
LVL 1

Author Comment

by:AngelFireMateo
ID: 6165881
I want  to do it in Delphi not in C
0
 
LVL 17

Expert Comment

by:inthe
ID: 6166010
do what ?
(i mean what commands in particular?)
0
 
LVL 44

Expert Comment

by:CrazyOne
ID: 6166403
Yeah, what is the commands you want to pass? It makes a difference in how you go about doing it.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6166936
?

winexec('command.com /c dir /on /p',SW_SHOWNORMAL);

shows the current directory sorted by name pagewise
0
 
LVL 1

Author Comment

by:AngelFireMateo
ID: 6168630
Thanks a lot that's what I was looking for
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question