Most Popular


UNC path in login scripts

This is mostly a note to myself, but it may be useful for others. By default command processing for login scripts can be iffy since UNC paths aren't handled well. To get around this, the pushd command can be used. It changes directory to the specified path, and if it's UNC it maps a temporary drive path (MS KB 317379). To specify the path %~dp0 can be used (% is environment variable, ~ specifies arguments, d is expand drive, p is expand path, 0 is of course the script itself - see How do I parse a file name parameter into its' constituent parts? for details). So pushd %~dp0 maps the script directory to a temp drive and drops in for the rest of the script. I got the hint here.