Mick'in cevabına ve Phoshi'nin cevabına dayanarak aradığım çözümü buldum. Passed parametresinin bulunduğu ilk yeri bulmak için tüm PATHEXT'ler ve PATH'ler arasında dolaşan bir AutoIt betiği yarattım. Hem uzantı-az hem de uzatma-tam parametrelerini işler. Önce yerel çalışma dizinini, sonra çevre değişkenlerini arar. Her şeyi okuduğum kadarıyla, Windows bu komutu da aradı. İşte senaryo:
If $CmdLine[0] > 0 Then
$commandToFind = $CmdLine[1]
$matchFound = false
$foundPath = ""
$pathEnvironmentVariable = EnvGet("PATH")
$pathDirectories = StringSplit($pathEnvironmentVariable, ";", 2)
$pathExtensionsEnvironmentVariable = EnvGet("PATHEXT")
$pathExtensions = StringSplit($pathExtensionsEnvironmentVariable, ";", 2)
; Search the local directory first for the file
If FileExists($commandToFind) Then
$matchFound = true
$foundPath = @WorkingDir & "\" & $commandToFind
EndIf
For $pathExtension In $pathExtensions
$fullPath = @WorkingDir & "\" & $commandToFind & StringLower($pathExtension)
If FileExists($fullPath) Then
$matchFound = true
$foundPath = $fullPath
ExitLoop
EndIF
Next
If Not $matchFound == true Then
; Loop through all the individual directories located in the PATH environment variable
For $pathDirectory In $pathDirectories
If FileExists($pathDirectory) Then
$pathWithoutExtension = $pathDirectory & "\" & $commandToFind
; Check if the command exists in the current path. Most likely the parameter had the extension passed in
If FileExists($pathWithoutExtension) Then
$matchFound = true
$foundPath = $pathWithoutExtension
ExitLoop
EndIf
If Not $matchFound == true Then
; Loop through all possible system extensions to see if the file exists.
For $pathExtension In $pathExtensions
$fullPath = $pathWithoutExtension & StringLower($pathExtension)
If FileExists($fullPath) Then
$matchFound = true
$foundPath = $fullPath
ExitLoop
EndIf
Next
EndIf
If $matchFound == true Then
ExitLoop
EndIf
EndIf
Next
EndIf
If $matchFound == true Then
ConsoleWrite("Located at " & $foundPath & @CRLF)
Else
ConsoleWriteError("Unable to locate the command" & @CRLF)
EndIf
EndIf
Çalışması için, AutoIt (kısayol başlıklı Compile Script to .exe) ile birlikte gelen Aut2exe.exe programını çalıştırmanız ve "Konsol?" Seçeneğini işaretlemeniz gerekir. derlerken onay kutusu. Ben sadece varolan bir yol dizininde (benzeri C:\Windows\System32) attığım "which.exe" adlı bir dosyaya derlemek .