?
Solved

Net use * /d /y

Posted on 2006-11-28
8
Medium Priority
?
5,028 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: 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 1000 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 1000 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 Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This may not be a text book method to resolve VSS backup issues but it seemed to have worked on few of the Windows 2003 servers we had issues while performing a Volume Shadow Copy backup. If you have issues while performing a shadow copy backup usin…
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…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

718 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