In Linux, there is a command called which, which can find and display the directory where a command is located in Path.
In Linux:
[Adam @ I ase adam] $ which ls
/Bin/ls
[Adam @ I ase adam] $ which rm
/Bin/rm has a where.exe in the Resource Kitts of NT. It also has the same effect, but Resource Kit charges fees. Here we can make a batch file to implement this function.
Use NotePad to edit a which. bat file and store it in the Wi t directory or another Path variable. The content of the batch processing file is as follows:
@ Echo off Rem check command line parameters
If {% 1 }={} goto: Usage
For % I ({/{-) do if {% 1 }=%% I ?} Goto: Usage % I
Echo.: Rem checks the current directory to see if the file exists.
For % I (% 1) do if exist % ~ Nx % I (
Echo % ~ Fi
Goto: EOF
): Rem checks the file in Path.
For % I (% 1) do (
If exist % ~ $ PATH: I (
Echo % ~ $ PATH: I
) Else (
Echo Error: % 1 is not in the path !!!
Goto: Usage
)
)
Goto: EOF
: Usage
Echo.
Echo WHICH quot; filename"
Echo.
Echo input file description, returns the full path of the file!
Echo.
Let's test our program:
Microsoft Window 2000 [Versio 5.00.2195]
(C) Copyright 1985-1998 Microsoft Corp. C:> which WHICH quot; filename "input file description, return the full path of the file!
C:> which cmd.exe C: WI tsystem320000.exe C:> OK, test passed!