We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

Getting past net use: i: /delete

Ponthecomputer
on
Medium Priority
784 Views
Last Modified: 2012-05-06
I am trying to setup a login script to map an I: drive.

I have used this in the past with no problem:
@echo off
net use I: /delete
net use I: \\server1\share1

I will get "the network connection could not be found" if there is no mapping already. If there is a mapping that does exist for the I drive, it will not disconnect it and reconnect the new one to \\server1\share1.

Is there a way first delete a network drive and get past any errors if it's not already mapped so that the mapping can continue?





Comment
Watch Question

I have seen that happen when a drive is in "disconnected" state otherwise it should work and continue on.
At the begining of your script delete all mapped drives first just incase?

net use * /delete
net use /persistent:no
net use I: \\server1\share1

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Or in VBS if you prefer.
This will remove all drives then add then back

On Error Resume Next
      Set objNetwork = CreateObject("Wscript.Network")
      Set colDrives = objNetwork.EnumNetworkDrives
      For i = 0 to colDrives.Count-1 Step 2
            objNetwork.RemoveNetworkDrive colDrives.Item(i)
      Next
      objNetwork.MapNetworkDrive "i:" , "\\server1\share1"
      objNetwork.MapNetworkDrive "j:" , "\\server2\share2"
or

if EXIST l: "net use I: /delete"
net use I: \\server1\share1
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.