From your script:
If someone knows a better way to get the directory let me know
I haven't had a chance to test it in this script yet, but %~dp0% should work, even with a UNC path. See Using batch parameters for an explanation. Oh, and a "setlocal" at the beginning and "endlocal" at the end ...