Home > DeveloperSection > Forums > Launch WPF application using Process.Start
john rob

Total Post:108

Points:756
Posted on    November-14-2013 3:19 AM

 C# C# 
Ratings:


 1 Reply(s)
 1898  View(s)
Rate this:

I am attempting to launch a wpf application using Process.Start.

var programPath = @"C:\Users\user\Documents\Program Directory\program.exe";

if(!File.Exists(programPath))

{

     MessageBox.Show("The program.exe file does not exist! Cannot launch.");

     return;

}

Process.Start(programPath);

My WPF process flashes in the task manager briefly before immediately closing.



ezra heywood
ezra heywood

Total Post:145

Points:1019
Posted on    November-14-2013 4:51 AM

Hi John,

Process proc = new Process();

proc.StartInfo.FileName = programPath;

proc.StartInfo.WorkingDirectory = Path.GetDirectoryName(programPath);

proc.Start();

The trick was to set the working directory to the path of the WPF application, rather than the working directory of the launching application.

Don't want to miss updates? Please click the below button!

Follow MindStick