Urwish Patel
Urwish Patel

Reputation: 11

Run Console application by providing one argument using web application

I have a console application called DocToPDF.exe on the desktop. I need to run it on the button click of a web application.I figured out how to run the application. The question is, the console application takes one argument.I need to figure out the way to pass the argument.The argument to be passed is "3750" Here is my code

   System.Diagnostics.Process process = new System.Diagnostics.Process();
    process.StartInfo.FileName = "cmd";
    process.StartInfo.WorkingDirectory = @"C:\Users\itadmin\Desktop\DocToPDF\DocToPDF\DocToPDF\bin\Debug";

    process.StartInfo.Arguments= "/c \"" + "DocToPDF.exe" + "\"";
    process.StartInfo.UseShellExecute = false;
    process.StartInfo.RedirectStandardInput = true;
    process.Start();

And this is my console application that accepts the parameter using Console.Readline

  Console.Write("Enter Merchant Acct # : ");
  string strApprId = Console.ReadLine();
  strApprId = strApprId.Trim();
  Console.WriteLine("Something awesome is being processed......... ");

Upvotes: 0

Views: 2455

Answers (1)

idiotbox
idiotbox

Reputation: 69

You can use

System.Diagnostics.Process pr=new System.Diagnostics.Process();
pr.StartInfo.Arguments = "Specify arguments here";             
pr.StartInfo.FileName="Specify.exe file complete path here";
pr.Start();

Upvotes: 2

Related Questions