Question

I have a question concerning net use. is there a way to delete multiple mapped drives connected to a single host? For example, I want to delete drives X and Y in one go using only one command. Is there a way to delete both X and Y since they share the same "hostname". If I am any bit unclear, please let me know. The following is an instance of what I am describing.

Status Local Remote Network


OK -> X: -> \hostname\dir1 Microsoft Windows Network

OK -> Y: -> \hostname\dir2 Microsoft Windows Network

OK -> Z: -> \hostname2\dir1 Microsoft Windows Network

The command completed successfully.

I know the net use /delete * command will delete all, but I want to save drive Z. Again, using only one command. Any ideas?

Était-ce utile?

La solution

Assuming that you want to use a command such as

unmap x y

then unmap.bat could be

@echo off
setlocal
:loop
set target=%1
if defined target net use %1: /delete &shift&goto loop

should do the task. %1 is the first parameter; the shift moves the parameters down so %2 becomes %1, etc.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top