0

I want to launch an application given only the application name, and not the path -- I don't know where exactly the user would have installed the application. The user can install an application in any path.

For example, if the user provides an application name like 'test.exe', I need to get the path and launch the application (using process.start).

Here is my code so far. What I'm currently doing is hard-coding the path, but I need help figuring out how to search for it instead.

protected void linkBPD_click(object sender, EventArgs e)
{
    string str = @"C:\Program Files\test\testProcess Capture\Common\capture";

    if (str != null)
    {
        Process process3 = new Process();
        process3.StartInfo.FileName = str;
        process3.Start();
    }
    else
    {
        System.Diagnostics.Process process1 = new System.Diagnostics.Process();

        // Working directory of .exe file. 
        process1.StartInfo.WorkingDirectory = Request.MapPath("~/");

        // exe file name. 
        process1.StartInfo.FileName = Request.MapPath("TestCapture.exe");
        process1.StartInfo.Arguments = " ";
        process1.StartInfo.LoadUserProfile = true;
        process1.Start();
    }
}
Michael0x2a
  • 58,192
  • 30
  • 175
  • 224
neyati
  • 1
  • 1

0 Answers0