here I will introduce three ugly tricks to do one simple task -- get the batch file path from inside
1. very ugly, appears very sophisticated, very profound
for /f %%i in ("%0") do set curpath=%%~dpi
cd /d %curpath%
[%0 returns the file path and name that your typed at command prompt to run the batch, and ~dp means to get drive and path]
2. much more simpler, and easier to understand
cd /d %~dp0
[see explanation in item 1]
3. simple and maybe can not be simpler
cd /d %0\..
[do I need to explain? ]