Solved

execute dos commands

Posted on 2001-06-07
9
170 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
Technology Partners: 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
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…

740 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