Link to home
Start Free TrialLog in
Avatar of PeterdeB
PeterdeBFlag for Netherlands

asked on

How to run a DOS app with parameters and redirect output to memo and if success enable a button?

Hi Folks!

I want to run a Dos application >cdimage.exe< which requires some parameters> [options] -sourceroot -targetfile< and of which the output should be directed to a memo on my form rather than the black ol' DOS screen. Preferrably without seeing any DOS screen.
This 'party' should be started by a button click and if it succeeds it should enable another button.

This isn't really one question but I'll reward it generously > 400 for him who provides the working sample to get this thing going.
If you need more info please let me know. Working samples only > since I jsut had my share of trying to get this thing working without acceptable result :)

Regards and respect fly out to all of ya!

Peter

Ps in case several people respond with working samples the first copy&paste sample wins ofcourse :)
Avatar of Mohammed Nasman
Mohammed Nasman
Flag of Palestine, State of image

Hello

 Read this tip about showing the Dos command output into memo, modify it to your application, then parse the output to determined if the operations succeed or not

Capture the output from a DOS (command/console) Window
http://delphi.about.com/cs/adptips2001/a/bltip0201_2.htm

HTH

>> Preferrably without seeing any DOS screen.

In order to suppress DOS, screen, you have to right-click on the "DOS application" in Windows Explorer.
Then modify default behavior by selecting Properties option in Popup menu.   I do not remember exact TAB name or button name, but you just need
to look in "Properties".  You will find an option to suppress the DOS window.

Once you change this, next time you run this DOS application, it should not open BLACK DOS window.

HTH
ASKER CERTIFIED SOLUTION
Avatar of BigRat
BigRat
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of robert_marquardt
robert_marquardt

Have a look at the installers of the JCL or JVCL. They both run dcc32.exe that way.
http://jcl.sf.net or http://jvcl.sf.net
Avatar of PeterdeB

ASKER

Hi Folks!

First of all thanks for responding all of you!
Then  ehm let's see > I followed the link provided by mnasman and after some fiddling managed to get it working that is except for the checking thingie.
Then ashok111 > I want to do this by code rather than doing it manually myself but perhaps I should have made that more clear.
Then BigRat > wow > I'll go and check that out right away and I already ran into the double line feed thingie only I had no idea whatsoever what caused it, now I do.
And robert_marquardt > tnx for the tip > I'm a bit familiar with the jcl and jvcl stuff and had already taken a look into the examples directory where a createprocess demo resides. Can't say I fully understood all I read but the major part didn't seem too complicated.

I'm quite overwhelmed with your replies I must say, didn't expect so many in so little time > this question is answered now but it will take me some time to return and handle the points > so in case  others read this > this question is answered I only have to reward and will do so in a couple of hours. First I have to take a look at the piece of code from BigRat.

I will return > my regards and appreciation for all the effort you put into helping me with this issue!

Greetz from Holland!

Peter :)
>>I will return

Tot ziens!
Hahhahaah is dat even een verrassing! LOL Ik neem tenminste aan dat ik hier met een rasechte kaaskop te maken heb of wellicht een zuiderbuur? LOL LOL hier heb ik niet van terug! Ik zou bijna schrijven: You bring a smile upon my face maar dat kan dan net zoi goed in het Hollands volgesn mij hahahaa.

Nou even kijken want ik heb zo n akelig vermoeden dat wanneer men hier Nederlands gaat lezen er nogal wat replies zullen komen maar dan vermoedleijk niet zozeer mbt het programmeren maar mbt de gesproken taal lol. Dus vooruit hier gaan we verrtalen die zooi:

Hhahhah what a surprise! LOL I pressume I've run into a die hard Cheesehead here or perhaps a Belgian. LOL LOL I'm speechless. I almost wrote: Jij tovert een lach op mijn gezicht but I can do that in Dutch as well apparently hahaha.

De rest mogen ze zelf uitzoeken cheeers mate!

Ik kwam je de punten geven trouwens!

Regards Peter
The points fly out to BigRat for providing the working sample. All the others thanks for your replies anyway. I learn from you.

Regards Peter
>> dat ik hier met een rasechte kaaskop te maken heb of wellicht een zuiderbuur?

Not male, not Dutch, not German, not Belgian, not French, but French as first language.
Aha well then I'd better  give up :) I surely took you for a guy, women aren't that common in this area or perhaps I fail to distinguish them from eachother but ah well most of the names chosen by people don't really point out what sex it is. If your name would have been SuzanneX then I would have known :)

Regards and respect and tnx for your respons!

Peter
No, no, no, no, I don't give up yet > then you're African!! Right?

Peter
>>If your name would have been SuzanneX

Well as a matter of fact it is!

>>then you're African!! Right?

No, EEC.
Are you serious? LOL it was the first name I came to think of. Then EEC.....*immersed in deep thoughts > without any result however lol *  Since you taught me some programming you might as well teach me some geography cause I have no idea what iyou mean with EEC......oh wait....wait wait.....East European Community!!!(???) LOL

if PeterDoesn'tKnow then PleaseTellHim :)

Regards,

Peter
LU
Aha wait yes now I know.....ah well then I consider you to be a southern neighbour anyway :)

regards,

Peter
BigRat,

You provided a wonderful solution but could you tell:

How to get the output characters on time, instead of collecting them AFTER the console app gets terminated?  For example, if you run NETSTAT.exe you will have all the output in a memo only after it has TERMINATED.

regards,

Liu, Wen
I have noticed that some apps write all their output just before terminating. The App I was using wrote ONE byte at a time which gives you CR/LF problems in the memo (or at least with TSynMemo). I can't see otherwise why the Pipe Thread should not get the data. It does get started before the issuing of the command.