Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

interface to cmd.exe

 

Hey all, I'm trying to start and Application that opens the cmd.exe (hidden) and write and read from it.

 

so far I seem to have fingered out the writing part!

 

but reading the output and also the code to hide it doesn't work.

 

can someone help with this (include is my test project I'm using for this)

 

thanx in advance

ApacheCompiler.zip

Edited by jorge
  • Administrators
Posted

Not sure about the why the cmd.exe is not being hidden but you will have problems trying to get the output from the cmd.exe. The problem is that the Readxxx methods will hang until there is something to read and block the execution of your main application.

You will need to launch cmd.exe in it's own thread and get it to raise an event back to the main app when it receives data.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted (edited)

ok now knowing what the problem was that it waits for input if there is none i fixed it by adding it to a thread :)

 

but now i hit a new problem...

 

when the textbox's max lenght is reached no text can be appended!

so how can i remove some text from the top to make the new text fit?

Edited by jorge
Posted

I can�t claim to be the world�s greatest programmer but I would store the output in a string or stringbuilder and copy the amount of data I want counting from the end to the textbox

 

Sorry, I don�t know how much data can be stored in a textbox.

Posted
I can�t claim to be the world�s greatest programmer but I would store the output in a string or stringbuilder and copy the amount of data I want counting from the end to the textbox

 

Sorry, I don�t know how much data can be stored in a textbox.

 

maybe i'll go for a rtf, i do'nt think it has a limit.

becouse i ahve no idea what a stringbuilder is.

Posted

Add CreateNoWindow = True

 

to the startInfo object.

 

Also, call Peek instead of Read or ReadLine from the standard output stream, otherwise the process wont realize it is waiting for input.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...