Click here to Skip to main content
15,902,198 members
Home / Discussions / C#
   

C#

 
GeneralRe: Download Pin
Pete O'Hanlon25-Mar-08 3:28
mvePete O'Hanlon25-Mar-08 3:28 
GeneralRe: Download Pin
ellllllllie25-Mar-08 5:08
ellllllllie25-Mar-08 5:08 
GeneralRe: Download Pin
Pete O'Hanlon25-Mar-08 5:17
mvePete O'Hanlon25-Mar-08 5:17 
GeneralRe: Download Pin
ellllllllie25-Mar-08 5:37
ellllllllie25-Mar-08 5:37 
QuestionWhat is this problem? Pin
wsamuel24-Mar-08 22:51
wsamuel24-Mar-08 22:51 
AnswerRe: What is this problem?Urgent!!Please Help!! Pin
Gareth H25-Mar-08 0:01
Gareth H25-Mar-08 0:01 
GeneralRe: What is this problem?Urgent!!Please Help!! Pin
wsamuel25-Mar-08 1:55
wsamuel25-Mar-08 1:55 
GeneralRedirect standard input and output from C# to batch file Pin
Member 212296324-Mar-08 22:46
Member 212296324-Mar-08 22:46 
Hi,

I'm trying to run a batch file from my C# windows application.
this is my batch file:
@ECHO OFF


ECHO "GOOD MORNING %1%"

:ASK
SET /P ANSWER="Do you want to continue (y/n) ? "
IF "%ANSWER%" == "y" GOTO PRESS_YES
IF "%ANSWER%" == "Y" GOTO PRESS_YES
IF "%ANSWER%" == "n" GOTO PRESS_NO
IF "%ANSWER%" == "N" GOTO PRESS_NO
GOTO ASK

:PRESS_YES
notepad

:PRESS_NO
exit 1

and this is my c# code:
Process pepprocess = new Process();

pepprocess.StartInfo.FileName = "cmd.exe";
pepprocess.StartInfo.Arguments = "/c helloworld.bat GIDI";
pepprocess.StartInfo.UseShellExecute = false;
pepprocess.StartInfo.RedirectStandardInput = true;
pepprocess.StartInfo.RedirectStandardOutput = true;
pepprocess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
pepprocess.StartInfo.CreateNoWindow = true;
pepprocess.Start();

StreamWriter sw = pepprocess.StandardInput;
StreamReader rd = pepprocess.StandardOutput;

while (!rd.EndOfStream)
{
string line = rd.ReadLine();


richTextBox1.Text = line;
if (line.Contains("?"))
{
sw.WriteLine("y");
}
}

my problem is that when i get to the question line, the process is stuck.
the purpose of my c# program is to show the output of the batch file in a windows form, and get answers from the user and send it back to the batch file.

can anyone help me?

thanks,
Gidi.
GeneralRe: Redirect standard input and output from C# to batch file Pin
Gareth H25-Mar-08 0:10
Gareth H25-Mar-08 0:10 
GeneralRe: Redirect standard input and output from C# to batch file Pin
m@u25-Mar-08 0:15
m@u25-Mar-08 0:15 
Generalcheck box inside the gridview Pin
chithra.r24-Mar-08 21:27
chithra.r24-Mar-08 21:27 
GeneralRe: check box inside the gridview Pin
That's Aragon24-Mar-08 23:16
That's Aragon24-Mar-08 23:16 
GeneralRe: check box inside the gridview Pin
chithra.r24-Mar-08 23:57
chithra.r24-Mar-08 23:57 
JokeRe: check box inside the gridview Pin
Nouman Bhatti24-Mar-08 23:49
Nouman Bhatti24-Mar-08 23:49 
GeneralLazy Insert Query Pin
Syed Shahid Hussain24-Mar-08 21:20
Syed Shahid Hussain24-Mar-08 21:20 
GeneralRe: Lazy Insert Query Pin
Gareth H24-Mar-08 22:22
Gareth H24-Mar-08 22:22 
GeneralRe: Lazy Insert Query Pin
Abdul Rahman Hamidy25-Mar-08 0:34
Abdul Rahman Hamidy25-Mar-08 0:34 
GeneralRe: Lazy Insert Query Pin
sarvesh.upadhyay25-Mar-08 1:23
professionalsarvesh.upadhyay25-Mar-08 1:23 
GeneralMyNeoReport Pin
Abdul Rahman Hamidy24-Mar-08 20:25
Abdul Rahman Hamidy24-Mar-08 20:25 
GeneralRe: MyNeoReport Pin
Christian Graus24-Mar-08 20:56
protectorChristian Graus24-Mar-08 20:56 
GeneralRe: MyNeoReport Pin
Pete O'Hanlon25-Mar-08 4:35
mvePete O'Hanlon25-Mar-08 4:35 
QuestionHow to Handle this Pin
Krazy Programmer24-Mar-08 20:01
Krazy Programmer24-Mar-08 20:01 
GeneralRe: How to Handle this Pin
Rajasekharan Vengalil24-Mar-08 20:28
Rajasekharan Vengalil24-Mar-08 20:28 
GeneralRe: How to Handle this Pin
Christian Graus24-Mar-08 20:58
protectorChristian Graus24-Mar-08 20:58 
QuestionNeed Help....don't wnat a space ? Pin
pakpatel24-Mar-08 19:22
pakpatel24-Mar-08 19:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.