Solved

execute dos commands

Posted on 2001-06-07
9
159 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:
mnasman 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

746 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

12 Experts available now in Live!

Get 1:1 Help Now