简体   繁体   中英

c# How does Process.Start() method automatically know where files are located?

If I feed Process.Start(); the parameters "Firefox" , Notepad or "cmd" it runs those programs like their location is built in, but with other programs I have to specify the program's directory for it to work.

How does it automatically know where some programs located, and why only those programs and not others?

My code:

using System;
using System.Diagnostics;

namespace Testing
{
 public class MainClass
 {
   static void Main()
   {
      Process.Start("Firefox");    // Works
      Process.Start("Notepad");    // Works 
      Process.Start(@"C:\Users\user\Desktop\Steam");   // Works too
      Process.Start("Steam");      // This line gives me "The System cannot find the file specified"(run-time error)
    }
  }
}

I think it depends on Environment variables in Windows. or type PATH in cmd and observe paths, where *.exe files can be found automatically.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM