I do not think that's possible. At the beginning of your script, you can use:
net use /delete 2>nul net use g: \\server\sharename /persistent:no
Or you can try pushd instead of net use ...
If Command Extensions are enabled the PUSHD command accepts network paths in addition to the normal drive letter and path. If a network path is specified, PUSHD will create a temporary drive letter that points to that specified network resource and then change the current drive and directory, using the newly defined drive letter. Temporary drive letters are allocated from Z: on down, using the first unused drive letter found.
Thus, you will always be correctly configured correctly configured drive.
jftuga
source share