Windows – Script to disconnect mapped network location

network-sharesscriptwindowswindows-nt-4

I have a user who needs to map a certain network location to drive O:. Every so often, this drive loses it's map to O:, but will show up under different letters, such as H:, K:, and L:. The normal procedure is for him to call Helpdesk (me) to come down and unmap/remap the drive to the proper letter.

During the remap process, I make sure to check the box Remap on login but that setting doesn't seem to take hold.

Is there any way to script this task? Normally, I would use net use /delete \\server\share or net use x: /delete (where x: is the drive letter), but the first one does not work as there is a letter assigned to the path, and the second one doesn't work as the letter it remaps to isn't always the same one.

System is Windows NT (we use specialized software that hasn't had an update in a while).

Best Answer

As long as there are no other shares you are trying to save you can use the following in a batch or logon script:

 NET USE * /delete
 NET USE O: \\server\share

This will remove all assigned (*) shares and set it to the drive/path you want.