Mapping a Windows drive using the next available drive letter

You can have the system pick the next available drive letter. Use the following syntax:
<driveletter>?=//<directory path>
For example, you can set _MAP as follows:
X?=//server/share
In this case the system does not map a drive to X. Instead, it maps to the next available drive, and stores the drive letter it selected in a variable named _MAP_X. If the selected drive is F, the _MAP_X variable's value is "F:". You can use the variable to access the mapping.

You can use multiple mappings as follows:

X?=//server/share; Y?=//server/public

You can use any letter you want, and you can even use multiple mappings, as in the following example:

The example also creates the following variables:

Note: If you use the next available drive syntax when targeting a Windows® system that uses Cygwin, you must escape the question mark with a backslash as follows:
Y\?=//server/share

Feedback