Announcement

Collapse
No announcement yet.

Find EXE in Environment Path

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Find EXE in Environment Path

    I know i could use Environ$ to walk through the directories of PATH, looking for an EXE - such as WinWord.exe.

    But, isn't there an API that would simplify the search?

  • #2
    Gary,

    Just try and start or load an EXE of the name you want. If it exists in the path it will either start or load as a file. Sounds crude but should work OK.
    hutch at movsd dot com
    The MASM Forum - SLL Modules and PB Libraries

    http://www.masm32.com/board/index.php?board=69.0

    Comment


    • #3
      How about using:

      WHERE [/R dir] [/Q] [/F] [/T] pattern...

      Description:
      Displays the location of files that match the search pattern.
      By default, the search is done along the current directory and
      in the paths specified by the PATH environment variable.​

      (Type WHERE by itself in a CLI for more info)

      Comment


      • #4
        Originally posted by Gary Beene View Post
        I know i could use Environ$ to walk through the directories of PATH, looking for an EXE - such as WinWord.exe.
        You won't find Winword.exe that way. The Office directories are not in the Path.
        You will find that most application executables on your computer are NOT in the path.

        The usual way to find the location of executables is using an extension that they are linked to. i.e. find the application that opens .docx files etc.
        Various methods of doing that have been discussed here in the past.


        Comment


        • #5
          Example using "everything" sdk with "everything" running in background".

          Last edited by Mike Doty; 25 Jan 2023, 08:32 AM.

          Comment


          • #6
            Howdy, Mike!

            In some of my apps I make use of the command line utility es.exe. It's provided by the makers of EveryThing and allows me to search the database that EveryThing creates. It works exceptionally well and gives an immediate answer - no wait time to speak of. But it does require that EveryThing is working in the background - not something I can depend on being true for most users.

            Howdy, Steve!

            Yes, but that does mean the app will open. If all I wanted to know is whether the app would run when used with Shell, that approach gives a different result.

            Howdy, Stuart!

            That's good to know. But, the utility Where will find winword.exe anyway? I suspect it's nowhere as quick as es.exe, but at least I'd know it's on a user's PC.

            Comment


            • #7
              Thanks Gary.
              I am playing with es.exe

              Comment


              • #8
                Howdy, Steve!

                Maybe I didn't understand your comment about "load as a file". Can you say more about that?

                Comment


                • #9
                  PATHSCAN$ might be helpful.

                  Comment


                  • #10
                    Originally posted by Gary Beene View Post
                    Howdy, Stuart!

                    That's good to know. But, the utility Where will find winword.exe anyway? I suspect it's nowhere as quick as es.exe, but at least I'd know it's on a user's PC.
                    No it won't find it on any normal iWindows installation since the MS Office hierarchy isn't in the path


                    As a matter of interest, Why do you want to the location of Winword.exe? You may be asking the wrong question.


                    Comment


                    • #11
                      WinAPI 'FindExecutable()" returns the full path for the executable associated with the named file, if you don't know the name of the EXE.

                      As noted earlier, the PB PATHSCAN verb finds any named file on the directory search list as specified in the PB doc; or you may use the WinAPI function SearchPath()

                      Michael Mattias
                      Tal Systems (retired)
                      Port Washington WI USA
                      [email protected]
                      http://www.talsystems.com

                      Comment


                      • #12
                        As far as an easy way to find any file on a given partition, the command line "dir /s filename" does the job. You can also use wildcards with the file name if you are not sure of the complete name.
                        hutch at movsd dot com
                        The MASM Forum - SLL Modules and PB Libraries

                        http://www.masm32.com/board/index.php?board=69.0

                        Comment


                        • #13
                          Originally posted by Michael Mattias View Post
                          As noted earlier, the PB PATHSCAN verb finds any named file on the directory search list as specified in the PB doc; or you may use the WinAPI function SearchPath()
                          AFAICT, PATHSCAN$ appears to be a simple PB wrapper around SearchPath()
                          Last edited by Stuart McLachlan; 25 Jan 2023, 09:24 PM.

                          Comment


                          • #14
                            Howdy, Stuart!

                            For any EXE, I just want to know if that EXE is in the PATH. WinWord.exe was just an example. I don't really care where it is, only whether it is in the PATH and can then be executed with ShellExecute without having to use the full path in ShellExecute.

                            Comment


                            • #15
                              Originally posted by Gary Beene View Post
                              Howdy, Stuart!

                              For any EXE, I just want to know if that EXE is in the PATH. WinWord.exe was just an example. I don't really care where it is, only whether it is in the PATH and can then be executed with ShellExecute without having to use the full path in ShellExecute.
                              In which case, PATHSCAN$ is the simplest solution.

                              Comment


                              • #16
                                Agree with PATHSCAN$
                                Code:
                                FUNCTION PBMAIN AS LONG
                                 LOCAL sPathFound,sFileName AS STRING
                                 sFileName = "hh.exe"
                                 sPathFound = PATHSCAN$(PATH, sFileName)
                                 IF LEN(sPathFound) THEN ? sPathFound + sFileName ELSE ? sFileName + " not in path"
                                END FUNCTION

                                Comment

                                Working...
                                X