Ever wondered which exact executable will be executed when running a command from the command line? UNIXes and Linux have which(1) which tells that. There are implementations on Windows, but not one in batch language I was aware of :-)
So that naturally called for ugly things to be done. I wrote this a while ago and noticed that it does not always works correctly on Windows Vista. At the time of its writing I was working with Windows 2000 and it worked pretty well there. Somehow something is messing with extensions:UPDATE (2008–06–01): I found another bug that manifests
itself most prominently on Windows Vista x64, concerning paths with closing
parentheses in them (as happens when installing x86 applications there). That
means I have to do a bit escaping as soon
as those paths show up in the argument of a FOR loop.
Using ! and FOR /F seems
to work somehow, except that I only get a single token from that.
| Attachment | Size |
|---|---|
| which.cmd | 1.98 KB |
Comments
Post new comment