TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
usman.ghani
NA
1
0
Spawning New Processes and reading Output
Feb 22 2005 10:28 AM
I was trying to do this. 1. Spawn cmd.exe and have a dialog with it sending commands to it and getting the output. I did all the relevant things . All those properties and things , But I cant read the output , or I think the process exits itself. The code I am trying is given below. 2. I was trying to spawn bitsadmin.exe with the argument /list but got this error . BITSADMIN version 2.0 [ 6.6.2600.2180 ] BITS administration utility. (C) Copyright 2000-2004 Microsoft Corp. Unable to get console input mode - 0x80070006 The handle is invalid. // This is the the code I am using to try it out. private void button1_Click(object sender, EventArgs e) { Process p = new Process(); ProcessStartInfo pInfo = new ProcessStartInfo(); pInfo.RedirectStandardOutput = true; pInfo.RedirectStandardError = true; pInfo.RedirectStandardInput = true; pInfo.FileName = "bitsadmin.exe"; pInfo.Arguments = "/list"; pInfo.CreateNoWindow = true; pInfo.UseShellExecute = false; p.StartInfo = pInfo; p.EnableRaisingEvents = true; p.OutputDataReceived += new DataReceivedEventHandler(process1_OutputDataReceived); p.ErrorDataReceived += new DataReceivedEventHandler(process1_ErrorDataReceived); p.Exited += new EventHandler(process1_Exited); p.Start (); //p.StandardInput.WriteLine("dir"); } private void process1_OutputDataReceived(object sender, DataReceivedEventArgs e) { this.Text = "process1_OutputDataReceived"; textBox1.Text += e.Data + "\n"; } private void process1_ErrorDataReceived(object sender, DataReceivedEventArgs e) { this.Text = "process1_ErrorDataReceived"; textBox1.Text += e.Data + "\n"; } private void process1_Exited(object sender, EventArgs e) { this.Text = "process1_Exited"; Process p = sender as Process; textBox1.Text += p.StandardOutput.ReadToEnd() + "\n"; } }
Reply
Answers (
0
)
Drawing on a Form from another class.
Renaming TreeNode...