My solution to this on .BAT files is:
@echo off set "sourcefolder=%~dp0"
echo Source folder from this script is: %sourcefolder%
timeout 30