@echo off
set a=%~$PATH:1
If "%a%"=="" (Echo %1 not found) else (echo %a%)
Is a more polished version for the bat file.
--
--------------------------------------------------------------------------------------------------
How to lose a war in Iraq
http://webdiary.com.au/cms/?q=node/1335#comment-48641
=================================================
"David Candy" <.> wrote in message news:(E-Mail Removed)...
A one line bat file (folder only)
echo %~dp$PATH:1
or (full path to file)
echo %~$PATH:1
Batfile.bat programfile
eg
SearchPath.bat notepad.exe
Understand that this only applies to the command prompt. The GUI uses
1.. The directory from which the application loaded.
2.. The current directory for the parent process.
3.. The 32-bit Windows system directory. Use the GetSystemDirectory function to get the path of this directory.
Windows Me/98/95: The Windows system directory. Use the GetSystemDirectory function to get the path of this directory.
4.. The 16-bit Windows system directory. There is no function that obtains the path of this directory, but it is searched. The name of this directory is System.
5.. The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
6.. The directories that are listed in the PATH environment variable.
Also both will try all possibilities if you don't quote spaces.
The lpApplicationName parameter can be NULL. In that case, the module name must be the first white space-delimited token in the lpCommandLine string. If you are using a long file name that contains a space, use quoted strings to indicate where the file name ends and the arguments begin; otherwise, the file name is ambiguous. For example, consider the string "c:\program files\sub dir\program name". This string can be interpreted in a number of ways. The system tries to interpret the possibilities in the following order:
c:\program.exe files\sub dir\program name
c:\program files\sub.exe dir\program name
c:\program files\sub dir\program.exe name
c:\program files\sub dir\program name.exe
--
--------------------------------------------------------------------------------------------------
How to lose a war in Iraq
http://webdiary.com.au/cms/?q=node/1335#comment-48641
=================================================
"Tim Slattery" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> Tim Slattery <(E-Mail Removed)> wrote:
>
>>(E-Mail Removed) wrote:
>>
>>>How do I determine which component of the PATH environment variable was
>>>the first file path that had the binary being executed...
>>
>>There's a "where.exe" utililty that's lived on our LAN for ever and
>>ever that does exactly this. Searching for it on Google turned up
>>this:
>>
>>http://www.paulsadowski.com/WSH/cmdprogs.htm
>>
>>It includes several command-line utilities, "which" is among them.
>
>
> Note: I meant to say "which.exe" in the first paragraph, not
> "where.exe".
>
> --
> Tim Slattery
> MS MVP(DTS)
> (E-Mail Removed)