(view source code of which.kix as plain text)
; Check command line argumentIf $search = "" OR InStr( $search, "?" )
? "Which.kix, Version 1.00"
? "Locate the specified program file"
? "Port of Unix' WHICH command" ?
? "Usage: KIX32 WHICH.KIX $$SEARCH=filename[.ext]" ?
? "Where: " + Chr(34) + "filename" + Chr(34)
" is a file name only: no path, no wildcards" ?
? "Written by Rob van der Woude"
? "http://www.robvanderwoude.com" ?
Exit 2
EndIf
; Store PATH and PATHEXT in arrays$pathArray = Split( "@CurDir;%PATH%", ";", -1 )
$pathExtArray = Split( "%PATHEXT%;.DLL;.SYS;.OCX", ";", -1 )
; Reset search result variable$found = 0
; Search each directory until one match is foundFor Each $i In $pathArray
If $found = 0
$pathDir = $i ; Strip trailing backslash and/or dotIf Right( $i, 2 ) = "\."
$pathDir = SubStr( $i, 1, Len( $i ) - 2 )
Else
If Right( $i, 1 ) = "\"
$pathDir = SubStr( $i, 1, Len( $i ) -1 )
EndIf
EndIf
; Try without appending extension firstIf InStr( $search, "." )
If Exist( $pathDir + "\" + $search )
$result = $pathDir + "\" + $search
$found = 1
EndIf
Else
; Then try all the extensions from PATHEXTFor Each $j In $pathExtArray
If Exist( $pathDir + "\" + $search + $j )
$result = $pathDir + "\" + $search + $j
$found = 1
EndIf
Next
EndIf
EndIf
Next
; Display the resultIf $found = 0
? "-None-" ?
$ret = 1
Else
? $result ?
$ret = 0
EndIf
; Exit with return codeExit $ret
page last modified: 2025-10-11; loaded in 0.0049 seconds