Can a mapped network drive be reconnected from the command line?

Maybe try pushd \\server\share?


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!


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