mdavis1982
asked on
Executing DOS commands
Hi!
How can I execute a DOS command in Delphi, and get the results from it put into a memo?
ie. I want to execute a DIR command with some switches, and have the output from the DIR put into a memo. Also, I will need to use the rename command, although if I can get the file name from the DIR, then I can do this programmatically in Delphi!
I'm using Delphi 6 Enterprise... Thanks for your help...
mdavis1982
How can I execute a DOS command in Delphi, and get the results from it put into a memo?
ie. I want to execute a DIR command with some switches, and have the output from the DIR put into a memo. Also, I will need to use the rename command, although if I can get the file name from the DIR, then I can do this programmatically in Delphi!
I'm using Delphi 6 Enterprise... Thanks for your help...
mdavis1982
When someone has given you all the information you need to complete your task, look at thier comment box and in the top right you will see "accept comment as answer" click on it when you feel they have answered your question. the other time is when the user selects thier comment as answer, however this does not happen often because it's polite to let the user decide if it helped them or not.
-
Craig C.
-
Craig C.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks! That's great! Oh, and here's 20 extra points for answering my question! #:o)
Matt
Matt
1 - You could try using ShellExecute to run the command CMD.EXE or COMAMND.COM with the paramater of "/cDIR directory > LOG.TXT"
2 - You could create a batch file containing all the code you want WITH the redirection to a text file already done and then ShellExecute that batch file.
Once you've got the output file, you can load it into your memo.
3 - You could use something like the code that is available at ...
http://www.delphifreestuff.com/examples/redir.html
This code still stores the output into a file, but you could probably modify it to feed your memo instead.
I don't know if this code is D6 compatible, but it is a start point maybe.
Regards,
Richard Quadling.