Wednesday, April 4, 2012

Windows Command: How to get the script path

I had to do this a few times every now and then and I always forget the syntax, but I do remember how to get it: from for /? help.

%~0 is the first parameter, which is the full path of the script; ~dp0 will give you the drive and path without the filename, e.g. echo "%~dp0"

You can obviously also set that into a working environment variable and use it throughout the script.

Windows Command - script path

No comments :

Post a Comment