Solved

execute dos commands

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

thanks
0
Comment
Question by:AngelFireMateo
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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Convert Jpg /PNG To GIF 5 118
Delphi application Soap connection 5 94
Tviruailstringtree sort multi columns on header click 1 52
Firemonkey DbLookupComboBox equivalent ? 2 32
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

919 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now