Process in C#.. [modified]
-
Hi, I am creating a Process in C# and want to print my "strName" value to command prompt. This code is not printing any value , please let me know the right code. I know this code is wrong,,but if we pass Arguents then? string strName = "Alex"; Process pr = new Process(); pr.StartInfo.FileName = "cmd.exe"; pr.Start(); Thanks
modified on Friday, April 9, 2010 10:14 AM
-
Hi, I am creating a Process in C# and want to print my "strName" value to command prompt. This code is not printing any value , please let me know the right code. I know this code is wrong,,but if we pass Arguents then? string strName = "Alex"; Process pr = new Process(); pr.StartInfo.FileName = "cmd.exe"; pr.Start(); Thanks
modified on Friday, April 9, 2010 10:14 AM
Have you tried going into the project properties and building it as a Console Application? Then just do:
Console.WriteLine(strName);
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels) -
Have you tried going into the project properties and building it as a Console Application? Then just do:
Console.WriteLine(strName);
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels) -
Using this code , and where to add new line of code which prints value to commandprompt. string strName = "Alex"; Process pr = new Process(); pr.StartInfo.FileName = "cmd.exe"; pr.Start();
Ok, if you want to actually send commands to the prompt, as opposed to just outputting text, you can do that via standard input...
pr.StartInfo.FileName = "cmd.exe";
pr.StartInfo.UseShellExecute = false;
pr.StartInfo.RedirectStandardInput = true;
pr.Start();
pr.StartInput.WriteLine(strName);Of course, "Alex" isn't a command, so this is just going to give an error. If you're trying to do something else, you're going to have to be a little more clear, because your question is rather vague.
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels) -
Hi, I am creating a Process in C# and want to print my "strName" value to command prompt. This code is not printing any value , please let me know the right code. I know this code is wrong,,but if we pass Arguents then? string strName = "Alex"; Process pr = new Process(); pr.StartInfo.FileName = "cmd.exe"; pr.Start(); Thanks
modified on Friday, April 9, 2010 10:14 AM
Aha! Unless this is a homework assignment, take a look at my ProcessCommunicator[^].