Easy Question - howdo I call another program from C#?

D

dave

I've been experimenting with a couple of things, but
basically I want to call a batch file from (ASP.NET C#)
upon a button click, execute then exit. Unfortunately my
batch code isn't executing.I would love to put a status
bar in here too while my batch is executing. Please help

Here's the code
....
Process p = new Process();
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName
= "C:\\P4Root\\applications\\..some_app\\debug\\build.bat"
;

p.Start();
Response.Write(p.StandardOutput.ReadToEnd());
p.WaitForExit();

Response.Write("Writing");
Response.Write("<script>window.close();</script>");
 
G

Guest

What you have there looks good. don't forget that you can also add command line arguments using the p.StartInfo.Arguments string. Also, make sure that the execute permissions are set correctly and that the ASPNET account has full access to the file you are trying to access.
 

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