473,326 Members | 2,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Open new cmd from console application and write text in the new Cmd

Hi,
I want to open one new CMD from console application, write text into the new CMD and then coming back to the control on the old cmd. (like interactively working on the both)

please look into the below code

Expand|Select|Wrap|Line Numbers
  1. Process P1 = Process.Start(@"C:\WINDOWS\system32\cmd.exe");
  2. P1.StartInfo.RedirectStandardInput = true;
  3. P1.StartInfo.RedirectStandardOutput = true;
  4. P1.StartInfo.UseShellExecute = false;
  5. StreamWriter wr = P1.StandardInput;
  6. wr.WriteLine("First line in New Cmd");
  7. Console.WriteLine("First line in Old Cmd");
  8. wr.WriteLine("Second line in New Cmd");
  9. Console.WriteLine("Second line in Old Cmd");
it is giving the exception "StandardIn has not been redirected"

Please help me on this issue
Oct 23 '12 #1
1 2116
Rabbit
12,516 Expert Mod 8TB
You can't start a process and then set it's StartInfo parameters. It's too late by then, you've already started the process. Also, you're redirected the output but haven't specified where.
Oct 23 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Jesper Odgaard | last post by:
Hi, I have created a C# windows application. Is it possible to open a text console from a subroutine within an application using forms. brgds Jesper, DK
1
by: Mullin Yu | last post by:
But, I want is that I can have a Main app that will start a new process or kill one particular or all process. The process will open a console exe. But, I don't want the user to close the console...
1
by: AA | last post by:
Somebody know how to get a fixed line in a console application, so if you want to write a command or something in the console, you have always one fixed line where you can do that. Like a prompt, but...
5
by: Barry Mossman | last post by:
Hi, can I detect whether my class is running within the context of a Console application, vs say a WinForm's application ? also does anyone know whether the compiler or runtime is smart enough...
24
by: arnuld | last post by:
i want to create a console application in C++ . what can be the 1st step ? NOTE: i did use Google but that gives me some VC++ based links using non-standard libraries.
6
by: dolulob | last post by:
Hi, I'm trying to communicate with a console application through a c# program. the console application is micq a console based ICQ client. I want to be able to send an receive messages through...
0
by: Stephen Thomas | last post by:
Hi there I wonder if any one has encountered this problem or can suggest what is wrong. I am trying the a procedure from the msn site but get the following message: Error 1 The type or...
5
by: codingZZ | last post by:
How do you convert a console application to a windows service.Any recommendations? The following code is below using System; using System.Collections.Generic; using System.Linq; using...
2
by: xinnie | last post by:
Ok, I'm totally new at CSharp. I have written some codes in Visual Studio, console application. Here shown below : using System; using System.IO; using System.Net; using System.Text; using...
1
by: deeps khats | last post by:
Hello, Iam using C# console application, iam using mailchimp DLL as mailchimp incorporates 2 DLL mailchimp and cook computing i have added reference for both DLL.. using System; using...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.