473,406 Members | 2,620 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,406 software developers and data experts.

Opening new cmd and writing the text

Hi,

I want to open a command prompt from a console application in a separate window and write some lines of text in the new command prompt.

In the Below code it is not opening the new cmd and not writing the text...

Please help me on this...

Here is the code:
Expand|Select|Wrap|Line Numbers
  1. public static int Main(string[] args)
  2. {
  3.    int retValue = 0;
  4.    try
  5.    {
  6.  
  7.       ProcessStartInfo MyProcess = new ProcessStartInfo();
  8.       MyProcess.FileName = "cmd.exe";
  9.       MyProcess.UseShellExecute = false;
  10.       MyProcess.RedirectStandardInput = true;
  11.       MyProcess.RedirectStandardOutput = true;
  12.       MyProcess.CreateNoWindow = false;
  13.  
  14.       Process NewProcess = Process.Start(MyProcess);
  15.       NewProcess.StandardInput.WriteLine("echo Writing line in the new window");
  16.  
  17.      }
  18.      catch
  19.      {
  20.        // ---- Enter your exception handling code here -----
  21.  
  22.      }
  23.      return retValue;
  24. }
Oct 17 '12 #1
1 2089
rupali
25
Hello sreedhar34,

try using the below code:

Expand|Select|Wrap|Line Numbers
  1. static void Main(string[] args)
  2. {
  3.       Console.WriteLine("echo Writing line in the new window");
  4.       Console.ReadLine();
  5. }
Oct 18 '12 #2

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

Similar topics

4
by: Rob Meade | last post by:
Hi all, Ok - minor fly in my ointment... I have an application which was successfully writing data from submitted forms to a text file in a directory - in this case: /data/findata.txt ...
0
by: Marshal Antony | last post by:
Hi, I have a web service creates a # delimited text file on a server different than the web server per day for tracking databse transactions.All transactions will be writing to this same text...
7
by: Wodzu | last post by:
Hello there friends... Can someone show me how to write some text to file and then read it from that file? I will be very greatfull for any help, Best Regards, Wodzu
13
by: Tim Johnson | last post by:
Hello all: I have a page with two frames named "menu" and "display". An event handler in "menu" changes the src attribute for "display", resulting in a different page being loaded for each...
3
by: bbepristis | last post by:
Hey all I have this code that reads from one text file writes to another unless im on a certian line then it writes the new data however it only seems to do about 40 lines then quits and I cant...
8
by: hazmaz | last post by:
I am writing a program will have a function where it opens a text file, and fills a list box line by line from the text file. It works fine, except for when I tried to load a dictionary which is ~...
3
by: =?Utf-8?B?am9obmFicmFoYW0xMDE=?= | last post by:
hello all, I've already posted a thread with the same problem but couldn't satisfactory answer. Let's come to the point. I can write some text to a text file with WriteAllText method. How can I...
1
by: engggirl3000 | last post by:
Another question I have, what is the difference between reading a text file to a program and opening a text file in the program? A sample of one of the text files is formatted like this: 3 ...
2
by: Clive Green | last post by:
Hello peeps, I am using PHP 5.2.2 together with MP3_Id (a PEAR module for reading and writing MP3 tags). I have been using PHP on the command line (Mac OS X Unix shell, to be precise), and am...
1
by: manu | last post by:
Hi, Can anyone please tell me the difference of opening file in Binary mode or in Text mode?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.