Running .exe file without specifying C # path

How can I run an exe file with C # code? So I have this:

Process.Start( @"C:\Program Files (x86)\Photoshop\Photoshop.exe"); 

But the path may be different in other machines. So, are there any ideas for running .exe with another way?

Thanks!

+5
source share
3 answers

I have found a solution.

 Activator.CreateInstance(Type.GetTypeFromProgID("Photoshop.Application")); 
+7
source

No, you cannot run an exe file without knowing its location.

An โ€œexceptionโ€ is if the executable directory is in the PATH environment variable, therefore:

 Process.Start("notepad.exe"); 

work.

+1
source

If I understand you correctly, the executable is within your reach, so just put it in the project directory and do not specify any path (by default, this is a relative path):

 Process.Start("Photoshop.exe"); 
0
source

Source: https://habr.com/ru/post/1260558/


All Articles