Use "%~f0" to get the full path of rebat.bat to correctly locate the rebar script. Also put the script name in quotes when passing it to escript.exe to correctly handle paths with spaces.