Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

execute dos commands

Posted on 2001-06-07
9
Medium Priority
?
187 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 150 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
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!

 
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

610 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