Don't know if this is the best way, but you can just loop through the paths
in the PATH environment variable and look for the file in each one. Here's
a console app that does it:
Imports System.Environment
Imports System.IO
Module Module1
Sub Main()
Dim fileToFind As String = "Notepad.exe"
For Each pathName As String In
GetEnvironmentVariable("path").Split(";")
Dim fullPath As String = pathName & "\" & fileToFind
If File.Exists(fullPath) Then
Console.WriteLine(fullPath)
End If
Next
End Sub
End Module
- Scott Swigart
"Phil Galey" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> In VB.NET, when you use shell or have a process object point to and run a
> separate application that is installed on the machine, is there a way of
> determining the path to the executable? I've been having the user point
> to
> it using the Open File Dialog from an Options menu item, but the program
> should be able to determine the path to a named program without relying on
> user intervention.
>
> Thanks.
>
>
|