PC Review


Reply
Thread Tools Rate Thread

Determining which PATH component is used to find a binary in XP

 
 
bagarow@yahoo.com
Guest
Posts: n/a
 
      10th May 2006
Hi

How do I determine which component of the PATH environment variable was
the first file path that had the binary being executed...

e.g. if there is java.exe in C:\Windows\system 32 and in C:\Program
Files\Java\jdk1.5.0_02\bin and the PATH variable contains
C:\Windows\system32 before
c:\Program Files\Java\jdk1.5.0_02, then I know if I execute java.exe it
comes from C:\Windows\system32.

Is there a utility that will automatically determine the source of the
executable? I suppose I could write one that would search each
component of the PATH variable in order. But if there is an existing
utility i would like to use that instead.

Thanks
Bob

 
Reply With Quote
 
 
 
 
Doug Knox MS-MVP
Guest
Posts: n/a
 
      10th May 2006
The PATH is parsed in order of the entries, so Windows\System32 will be checked first.

--
Doug Knox, MS-MVP Windows Media Center\Windows Powered Smart Display\Security
Win 95/98/Me/XP Tweaks and Fixes
http://www.dougknox.com
--------------------------------
Per user Group Policy Restrictions for XP Home and XP Pro
http://www.dougknox.com/xp/utils/xp_securityconsole.htm
--------------------------------
Please reply only to the newsgroup so all may benefit.
Unsolicited e-mail is not answered.

<(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> Hi
>
> How do I determine which component of the PATH environment variable was
> the first file path that had the binary being executed...
>
> e.g. if there is java.exe in C:\Windows\system 32 and in C:\Program
> Files\Java\jdk1.5.0_02\bin and the PATH variable contains
> C:\Windows\system32 before
> c:\Program Files\Java\jdk1.5.0_02, then I know if I execute java.exe it
> comes from C:\Windows\system32.
>
> Is there a utility that will automatically determine the source of the
> executable? I suppose I could write one that would search each
> component of the PATH variable in order. But if there is an existing
> utility i would like to use that instead.
>
> Thanks
> Bob
>

 
Reply With Quote
 
Jon
Guest
Posts: n/a
 
      10th May 2006

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi
>
> How do I determine which component of the PATH environment variable was
> the first file path that had the binary being executed...
>
> e.g. if there is java.exe in C:\Windows\system 32 and in C:\Program
> Files\Java\jdk1.5.0_02\bin and the PATH variable contains
> C:\Windows\system32 before
> c:\Program Files\Java\jdk1.5.0_02, then I know if I execute java.exe it
> comes from C:\Windows\system32.
>
> Is there a utility that will automatically determine the source of the
> executable? I suppose I could write one that would search each
> component of the PATH variable in order. But if there is an existing
> utility i would like to use that instead.
>
> Thanks
> Bob
>


Try filemon
http://www.sysinternals.com/Utilities/Filemon.html

Jon

 
Reply With Quote
 
Tim Slattery
Guest
Posts: n/a
 
      11th May 2006
(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.

--
Tim Slattery
MS MVP(DTS)
(E-Mail Removed)
 
Reply With Quote
 
Tim Slattery
Guest
Posts: n/a
 
      11th May 2006
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)
 
Reply With Quote
 
David Candy
Guest
Posts: n/a
 
      11th May 2006
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)

 
Reply With Quote
 
David Candy
Guest
Posts: n/a
 
      13th May 2006
@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)

 
Reply With Quote
 
Plato
Guest
Posts: n/a
 
      13th May 2006
http://www.bootdisk.com/html.htm

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding an XP Embedded binary to my own custom component jimt Windows XP Embedded 5 29th Jun 2007 02:14 AM
Determining parent form of Component =?Utf-8?B?Um9iZXJ0IE1hZ251c3Nvbg==?= Microsoft Dot NET Framework Forms 2 20th Oct 2005 02:35 PM
Determining ContentType for binary attachments Stephen Walch Microsoft ASP .NET 2 6th Jan 2005 02:32 AM
Determining if a path is a network path (aka mapped drive - PathIsNetworkPath) Robert Munroe Microsoft C# .NET 0 10th Dec 2003 10:35 PM
determining correct ARC path? Tim Stephens Microsoft Windows 2000 Setup 0 5th Sep 2003 11:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:01 AM.