Solved

Net use * /d /y

Posted on 2006-11-28
8
4,856 Views
Last Modified: 2008-02-26
Hi guys!

Often I have to map up to 10 drive letters to different machines.
When I log on, I get 2 drive mappings through logon script, they are S: and T:.

What Id like to find is a quick way to remove all my drive mappings through script, except keep S: and T:
I cant use:
net use * /d /y
because that will remove S: and T:

Do you guys know how I could quickly remove all drive mappings in a batch file except retain S: and T: ?
Thanks guys

Simon
0
Comment
Question by:Simon336697
  • 4
  • 3
8 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 18030745
for /f "skip=3 tokens=2" %a in ('net use') do if not [%a]==S: if not [%a]==T: net use %a /del /y
0
 
LVL 1

Author Comment

by:Simon336697
ID: 18030863
Hi Sirbounty!

Thanks for your help on this mate.
I tried this script but it doesnt seem to remove the mapped drives Sirbounty.

Simon
0
 
LVL 1

Author Comment

by:Simon336697
ID: 18030899
Sirbounty!

Here is the output:

D:\>map.cmd
a] was unexpected at this time.

D:\>for /f "skip=3 tokens=2" a]==S: if not [ net use a /del /y
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 67

Assisted Solution

by:sirbounty
sirbounty earned 250 total points
ID: 18030912
type-o on my part...

for /f "skip=3 tokens=2" %a in ('net use') do if not [%a]==[S:] if not [%a]==[T:] net use %a /del /y
0
 
LVL 1

Author Comment

by:Simon336697
ID: 18030958
Sorry to be a pain:

D:\>simon.cmd
a] was unexpected at this time.

D:\>for /f "skip=3 tokens=2" a]==[S:] if not [] net use a /del /y

0
 
LVL 38

Accepted Solution

by:
Shift-3 earned 250 total points
ID: 18031102
Change each instance of %a to %%a if you're running it in a .cmd file.
0
 
LVL 1

Author Comment

by:Simon336697
ID: 18031188
Sir Bounty

Thanks mate that works.

Simon
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18032911
Had to cut the grass...glad you got it sorted. :^)
0

Featured Post

Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Preface Having the need * to contact many different companies with different infrastructures * do remote maintenance in their network required us to implement a more flexible routing solution. As RAS, PPTP, L2TP and VPN Client connections are no…
Setting up a Microsoft WSUS update system is free relatively speaking if you have hard disk space and processor capacity.   However, WSUS can be a blessing and a curse. For example, there is nothing worse than approving updates and they just have…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question