Solved

Net use * /d /y

Posted on 2006-11-28
8
4,958 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
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
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 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

The HP utility "HP Lights-Out Online Configuration Utility for Windows Server 2003/2008" could be of great use when it comes to remotely configure a HP servers ILO WITHOUT rebooting the server. We would only need to create and run scripts using thi…
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 is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

617 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