I want to write a start up script to take an mapped drive, change the drive letter, then put a different share on the original drive. How can this be done?
I want to write a start up script to take an mapped drive, change the drive letter, then put a different share on the original drive. How can this be done?
Absolutely.
If for example the existing drive is X: and has \server1\shareA on it and you wanted to remap X: to Y:you could do it with a batch script.
If you need to pass credentials you'd have to add the username (and possibly the password if you want it to run totally automated. Note that it's a bad idea to do this with privileged accounts and there are way smarter ways. But for a quick change over this will do it
If you don't include the password it will prompt. You can save this in a .bat file and it will run just fine.
EDITED TO ADD more complete solution
So you want to take a drive mapping X: change it to Y: and then connect X: to the new share \server1\newshare? Here you go. You can of course still pass credentials if necessary.
The
for
loop parses out the existing share path for the drive letter you want to change. Then you disconnect it from x: reconnect it to y: and then connect the new thing to x: all in quick succession.Check out the NET USE command.
You will need to delete the current mapping, then remap with the desired drive letters and shares.
Where
X:
is the drive letter you want to map and\\newshare
is the location of the new share you want mapped