Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

On a daily basis I find myself in the Windows command prompt needing to access a network drive that is mapped but disconnected. I have yet to find a command that will reconnect this drive without unmapping and remapping (which leads to a password guessing game, since I don't own these computers). I would also like to be able to script this so every night the drive is reconnected if it has become disconnected somehow.

The fastest solution I currently have is to:

  1. Type "start." to open explorer,
  2. Alt-D to focus the address bar,
  3. type the drive letter I want and press enter, and wait for it to display the drive contents,
  4. then finally, close explorer and go back to the command prompt.

I know it's a minor inconvenience, but I'm often doing this through a slow VNC or PCAnywhere connection where doing anything through GUI is awful, so I'm just wondering if there's a better solution.

share|improve this question
1  
What happens when you `dir h:\`? –  wfaulk Oct 8 '09 at 6:08
1  
In stead of typing "start.<enter>" you can just do win-E and save 5 keystrokes ;-) –  fretje Oct 8 '09 at 13:21
    
I "solved" it by just using the \\server\share path instead of the mapped drive. You can just copy files if you need to. (That was my problem) –  Peterdk May 3 '13 at 11:41

9 Answers 9

up vote 12 down vote accepted

Maybe try pushd \\server\share?

share|improve this answer
1  
I'm not sure this is what I need. Pushd looks like it creates temporary drive letters; I already have a drive letter mapped, but the share is disconnected (it has a red X in explorer and is labeled "Disconnected Network Drive"). Maybe I am mistaken. –  Stephen Jennings Oct 8 '09 at 4:12
    
Yeah, I was thinking that accessing it that way might poke the drive into reconnecting. You can use popd to remove the drive letter. –  wfaulk Oct 8 '09 at 4:40
    
I will try it next time I encounter this. I suspect it will either fail saying the device is in use, or connect the wrong drive letter to the share. –  Stephen Jennings Oct 8 '09 at 5:47
    
I tried this and it actually did work. I first ran pushd to the share then popd to unmap the extra drive letter, and I found the mapped drive I wanted was connected again. This is definitely an upvote, and if I don't get a shorter answer in a couple days this will be accepted. –  Stephen Jennings Oct 8 '09 at 13:56

create a batch file (refreshletters.cmd) with these commands in it

(these will only work inside a batch file)

Tested on on Win7 and XP to refresh 'Disconnected' and 'Unavailable' driver letters in a console window (command line).

@echo off
net use |FIND ":" > %temp%\used.txt
FOR /F " tokens=1,2,3 delims= " %%i in (%temp%\used.txt) do (

  if %%i EQU Unavailable  (
    net use %%j %%k
    echo Activated %%j
   ) ELSE (
     if %%i EQU Disconnected (
       pushd .
       cd /d %%j
       dir . %>nul
       if NOT exist %%j\. (
          net use %%j /del /y
          net use %%j %%k
          echo Remapped %%j
          ) else (
             echo Fixed-up %%j
            )
       popd
       ) ELSE (
          echo Checked %%j
          )
     )
 )
share|improve this answer
    
Given that we don't know the OP's level of expertise, it may be a good idea to expand on your answer. –  Tog Nov 5 '13 at 14:44
    
net use works for me for Unavailable mapped drives in Win7. ty –  Mat M Nov 5 '13 at 20:36

I had a similar problem and discovered I could force a reconnection with a simple "dir x:" from the command line (where X: was the mapped but disconnected drive.) This was from a Server 2003 system to mapped drives on XP and Win7 computers.

I created a batch file, wake_network_drives.bat, with these two lines:

    dir x:
    dir z:

and set a scheduled task to run it nightly before the backup program that was failing because the drives were occasionally showing as disconnected.

share|improve this answer
    
This works. Even if the dir command gives you an error, it tends to wake up the disconnected network drive. This is the best answer of them all. –  3noch Sep 27 '12 at 20:59

I have the same problem with multiple connections, and it's intermittent. When I reboot the computer, sometimes the connection is "good" and sometimes not. I don't have the password problem since I'm on a company LAN, but still I have the other aspect of the problem.

I've created a batch file called ex.bat, and stored it (along with many other things) in a \util directory that I put in my path. I can type "ex h:" and it will run Windows Explorer and set it to go directly to the h: drive. Here is the batch file:

start explorer /e,/select,%1

This works, with a lot fewer keystrokes. Or if it doesn't work at first, hit the Enter key to open the h: root folder and display the contents. Or, type "ex h:\sub" where the subfolder "sub" exists.

This problem seems to have gotten a lot worse recently, perhaps due to one of the Windows XP security patches.

Another thing to try is on the server side. On Windows servers, modifying a Registry key is supposed to keep the server from disconnecting its connections on a timeout. I do this on pretty much all our servers. The file is:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters]
"autodisconnect"=dword:ffffffff
share|improve this answer

I have to start Windows 7 before I can run the VPN program which connects me to the company network drives. Therefore my network drives don't automatically reconnect, only opening them in Windows Explorer reconnects them.

I have made a small batch file to start the VPN, reconnect the network drives, and start some applications I always uses.

In my Batch file I have the following:

REM Connect VPN here...

REM Opens an Explorer window looking at T: forcing a reconnect
Start /min explorer t:\

timeout 3 /nobreak

REM Kill all Explorer windows beginning with "T_drive" in the title
Taskkill /fi "windowtitle eq T_drive*"

REM Finish starting up here...

exit

The Taskkill /fi "windowtitle eq" command is case sensitive!

share|improve this answer

If you aren't opposed to keeping these passwords in plain text in a batch you can script a delete and remap including credentials.

net use H: /delete
net use H: \\server\share /user:domain\user password /persistent:yes

I know it doesn't meet your requirement of not deleting the share, but it resolves the root of the problem of having to remember passwords.

share|improve this answer

This is probably a stupid question, but assuming your "disconnected" drive is H:, have you tried just changing directly to the drive?

It works for me under XPSP3:

C:\>net use
New connections will be remembered.


Status       Local     Remote                    Network

-------------------------------------------------------------------------------
Disconnected H:        \\xxxxxx\wfaulk           Microsoft Windows Network
OK                     \\xxxxxxx\business        Microsoft Windows Network
The command completed successfully.


C:\>h:

H:\>net use
New connections will be remembered.


Status       Local     Remote                    Network

-------------------------------------------------------------------------------
OK           H:        \\xxxxxx\wfaulk           Microsoft Windows Network
OK                     \\xxxxxxx\business        Microsoft Windows Network
The command completed successfully.
share|improve this answer
    
Command prompt does not let you switch to a network drive which is currently disconnected. At least not on the hundreds of computers I'm using this on (WinNT, Win2k, WinXP, WinXP Embedded). –  Stephen Jennings Oct 9 '09 at 3:49
1  
Weird. I swear it works for me. –  wfaulk Oct 9 '09 at 14:43
    
it works for me as well! –  Snark Oct 9 '09 at 14:47
    
I admit I have seen this work occasionally, but most of the time it does not. I don't know what determines one way or another, possibly whether or not there are saved credentials. –  Stephen Jennings Oct 10 '09 at 6:20
    
Oh, I bet that's it. I'm automatically authenticating using my domain credentials. –  wfaulk Oct 10 '09 at 15:33

I know you said "net use" didnt work for you - but here is what you could try.

Run a batch file with net use /DELETE option to remove the existing/persistent connections And then you could use net use with the /SAVECRED option to re-use the passowd credentials used int eh last succesful logon. I am not sure if this will address your problem but its worth looking into.

share|improve this answer
    
This isn't quite what I need, but this is definitely a useful thing to know. This solves another problem I've had. –  Stephen Jennings Oct 10 '09 at 6:18

Just type:

NET USE H: \\server\share

(where H: is your drive letter of course)

Type 'NET /? USE' to see all options this command gives you.

share|improve this answer
    
This does not work. The drive letter is already mapped, it's just disconnected (usually the other computer was rebooted). When you run this, it complains that the device is already in use. –  Stephen Jennings Oct 8 '09 at 5:41
    
This should work. Some time ago I had a similar problem, and I remember resolving it using NET USE. I don't recall the exact syntax however. Maybe it was just NET USE \\server\share or I deleted and recreated the mapping... –  Cd-MaN Oct 8 '09 at 6:07
    
Yes, I tested this just now and got "Local device name already in use." –  Stephen Jennings Oct 8 '09 at 13:54
    
It works for me... but I'm on Windows 7, and actually the drive reconnects by itself... Try NET USE H: simple (without the path), that should bring the connection back up. I forget how it used to be in XP. –  Zoran Oct 9 '09 at 9:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.