Advertisement
Alexqq11

2which

Dec 8th, 2015
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 0.31 KB | None | 0 0
  1. @echo off
  2. set way=%cd%
  3. set var1=%1
  4. set var2=%var1:~-4%
  5. set var3=%1.exe
  6. set answer=1
  7. if /I ".exe" EQU "%var2%" (set var3=%1)
  8. if EXIST %var3% (
  9.     set answer=%cd%\%var3%
  10.     ) else (FOR /F %%i IN ("%var3%") DO set answer=%%~$Path:i)
  11.  
  12. cd %answer% 2>null
  13. if ERRORLEVEL  1 ( echo %answer% )
  14. cd %way%
  15. exit /b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement