Reputation: 197
I am automating some batch files into a single C# application but not having much luck. I have the following batch file (and another 3) that I am trying to write in C#
"C:\Program Files\IIS Express\iisexpress.exe" /path:c:\windows\Microsoft.NET\Framework\v4.0.30319\ASP.NETWebAdminFiles /vpath:"/asp.netwebadminfiles" /port:61569 /clr:4.0 /ntlm
Here is the C# code I have found online but it fails:
using (Process proc = new Process())
{
proc.StartInfo.FileName = "iisexpress.exe";
proc.StartInfo.Arguments = @"/path:c:\windows\Microsoft.NET\Framework\v4.0.30319\ASP.NETWebAdminFiles /vpath:/asp.netwebadminfiles /port:61569 /clr:4.0 /ntlm";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.Start();
proc.WaitForExit();
Console.Out.WriteLine(proc.StandardOutput.ReadToEnd());
}
I get the following, with no help from Google:
An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll
Upvotes: 0
Views: 492
Reputation: 149518
You need to give Process.StartInfo.FileName
the full path to your exe:
proc.StartInfo.FileName = @"C:\Program Files\IIS Express\iisexpress.exe";
Upvotes: 4