Showing posts with label Performance. Show all posts
Showing posts with label Performance. Show all posts

Oct 22, 2009

Another good reason not to run program by its name in Windows

When searching for executable by its name Windows always looks in:
  • Current working directory
  • Windows system directory (use GetSystemDirectory() to obtain it)
  • Windows directory (use GetWindowsDirectory() to obtain it)
  • Directories listed in PATH environment variable
This list (I will refer to it as search directories) can be expanded with more directories when performing specific tasks.
If name does not contains file extension (for example notepad or attrib), Windows will use glob "name.*" to find file with extension that is listed in PATHEXT environment variable.

It's okay if you need just to run notepad or mspaint from command line. But what if you need to execute some program many times? Well, running it by its name is definitely not your choice. I'll try to explain why.