- Aug
- 29
- 0
Ever need to know if a given command is available within your batch file at runtime? This function lets you know if a command is available and what it's source is by using the internal WHICH command as a function:
The return value lets you know the type:
1: internal command
2: alias
3: external
4: batch
5: Executable extenstion
6: Windows file association
-1: unknown
{yes, it's a crazy, long function and I wish Rex would incorporate it directly into the API because I use it all the time}
Code:
which =%@exec[@set _which=%@left[3,%@word[3,%@execstr[which %1]]]]%@if[%_which eq int,1,%@if[%_which eq ali,2,%@if[%_which eq ext,3,%@if[%_which eq bat,4,%@if[%_which eq exe,5,%@if[%_which eq wit,6,%@if[%_which eq unk,-1,0]]]]]]]%+unset _which
The return value lets you know the type:
1: internal command
2: alias
3: external
4: batch
5: Executable extenstion
6: Windows file association
-1: unknown
{yes, it's a crazy, long function and I wish Rex would incorporate it directly into the API because I use it all the time}