Hello,
How could I delete the old network drive and add the new with one command in cmd, is this even possible ?
Best Regards
Hello,
How could I delete the old network drive and add the new with one command in cmd, is this even possible ?
Best Regards
To add and delete a network drive with cmd you can make use of the net use commands.
net use z: /delete && net use z: \\servername\share
If the reply was helpful please don't forget to upvote and/or accept as answer, thank you!
Best regards,
Leon
Hi @LeonLaude
Thank you for the answer, but is there a command that check if network drive is still shared and if not, he is deleted, and new one if is shared is added?
Best Regards,
Szymon
You can only check if the mapped network drive is already mounted, not sure if you can check if it's in use.
Hi,
You may refer to LeonLaude’s answer: net use z: /delete && net use z: \\servername\share.
Best Regards,
Mulder Zhang
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Hello, @SzymonRabiza-7107 and all.
Further to the archived thread at <https://social.technet.microsoft.com/Forums/en-US/f4460a73-6a42-47f8-950b-2f18e03c0a7e/impossible-to-remove-a-persistent-network-drive-mapping-when-logged-on-disconnected?forum=win10itprogeneral>; and the above answers; you may wish to use the following commands.
Net Use z: /Delete
Mountvol z: /d
if not exist z:\ (Net Use z: \\servername\share /Persistent:YES)
These three lines can be concatenated into a single command line expression, by using ampersands (&).
I have struggled for the last six months and have developed an elaborate batch file to remap my home network drives on my laptop; as Windows 10 doesn't always find them again. Today, the referenced archived thread pointed me to using both Net Use /d and Mountvol /d — as a pair. Kudos to @JackJack and @Grajon, as the net use and mountvol pair obviates the need to stop and restart file Explorer; which itself introduces other (potential) issues!
Best regards,
BosunDoug
PS. Per the original/archived thread, I too suspect this is an unresolved Windows 10 bug.
10 people are following this question.