Find executables on windows

MSDN, CreateProcess:

...If the filename does not contain a directory path, the system
searches
for the executable file in the following sequence:

- The directory from which the application loaded.

- The current directory for the parent process.

- Windows 95 and Windows 98: The Windows system directory.
   Use theGetSystemDirectory function to get the path of this directory.

- Windows NT: The 32-bit Windows system directory.
   Use the GetSystemDirectory function to get the path of this
directory.
   The name of this directory is SYSTEM32.

- Windows NT: The 16-bit Windows system directory.
   There is no Win32 function that obtains the path of this directory,
   but it is searched. The name of this directory is SYSTEM.

- The Windows directory. Use theGetWindowsDirectory function to get the

   path of this directory.

- The directories that are listed in the PATH environment variable.

erm, yes, that's it! :slight_smile:

cheers

Simon

···

-----Original Message-----
From: Ara.T.Howard [mailto:Ara.T.Howard@noaa.gov]
Sent: Tuesday, September 13, 2005 3:38 PM
To: ruby-talk ML
Subject: find executables on windows

in linux i'd do something (un-tested) like:

   def find_bin bin
     bin = nil
     path = ENV['PATH'].split File::PATH_SEPARATOR
     path.each do |dir|
       b = File::join dir, bin
       return b if File::executable? b
     end
     bin
   end

what would the equivalient be in windows? should the above
work or do i need
to check some other env vars?

cheers.

-a

i think i'll settle for PATH :wink:

-a

···

On Tue, 13 Sep 2005, Kroeger Simon (ext) wrote:

MSDN, CreateProcess:

...If the filename does not contain a directory path, the system
searches
for the executable file in the following sequence:

- The directory from which the application loaded.

- The current directory for the parent process.

- Windows 95 and Windows 98: The Windows system directory.
  Use theGetSystemDirectory function to get the path of this directory.

- Windows NT: The 32-bit Windows system directory.
  Use the GetSystemDirectory function to get the path of this
directory.
  The name of this directory is SYSTEM32.

- Windows NT: The 16-bit Windows system directory.
  There is no Win32 function that obtains the path of this directory,
  but it is searched. The name of this directory is SYSTEM.

- The Windows directory. Use theGetWindowsDirectory function to get the

  path of this directory.

- The directories that are listed in the PATH environment variable.

erm, yes, that's it! :slight_smile:

--

email :: ara [dot] t [dot] howard [at] noaa [dot] gov
phone :: 303.497.6469
Your life dwells amoung the causes of death
Like a lamp standing in a strong breeze. --Nagarjuna

===============================================================================