Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / October 2004

Tip: Looking for answers? Try searching our database.

Determining Path To A Separate Program

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Phil Galey - 27 Oct 2004 20:46 GMT
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.
Scott Swigart - 27 Oct 2004 21:25 GMT
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

> 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
[quoted text clipped - 5 lines]
>
> Thanks.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.