Starting application like: C:\Direct -a -b -c <C:\Script.src > C:\log.txt

S

SMichal

Hi,

how can I start new process with this kind of application ?

C:\Direct.exe -a -b -c <C:\Script.src > C:\log.txt

As you can see...I'll start appliaction ConnectDirect with 5 paramaters

-a = node
-b = username
-c = password

C:\Script.src = input file with script
C:\Log.txt = output file of direct.exe application

How can I start that application with using of Process class ?
There's a problem when I try to start it with this code - it doesnt work :-(

StringBuilder args1 = new StringBuilder();
args1.Append("-n" + localhost + " -u" + userName + " -p" +
password + " ");



Process myProcess = new Process();

myProcess.StartInfo.FileName = cdHome + "Direct.exe";

myProcess.StartInfo.Arguments = args1.ToString();

myProcess.StartInfo.UseShellExecute = false;

myProcess.StartInfo.RedirectStandardInput = true;

myProcess.StartInfo.RedirectStandardError = true;

myProcess.StartInfo.RedirectStandardOutput = true;



myProcess.Start();



// input

StreamWriter myStreamWriter = myProcess.StandardInput;

string[] procedData = File.ReadAllLines(prozessFile);

for (int i = 0; i < procedData.Length; i++)

{

myStreamWriter.WriteLine(procedData);

}

myStreamWriter.Close();

string output = myProcess.StandardOutput.ReadToEnd();
File.WriteAllText(temp + "StdOutLog.txt", output);



// error output z aplikace

string outputErr = myProcess.StandardError.ReadToEnd();

File.WriteAllText(temp + "StdErrorLog.txt", outputErr);



Is there some posibility to start it ? Mayby with CMD /c ??

Thx for any help or information
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top