How do you automount an SMB share in Windows 7? When I first login, the drive appears but is not "mounted". It is a mapped network drive, but iTunes will not find the music located on the server until I click the drive in Windows Explorer and mount the drive. It says in Windows Explorer that the drive is "disconnected".

  • Does it work better with the firewall disabled ?
    – harrymc
    Mar 15, 2013 at 8:45
  • Is this not more of an iTunes issue than a Windows issue?
    – Alan B
    Mar 21, 2013 at 8:58

7 Answers 7


You could try adding on logon via the 'net' command

For example,

net use z: \\server\share

You could get this to start at logon a number of ways - put it in a batch file and add to startup items, add it to task scheduler, or add it to the local group policy are three that come to mind (no doubt there are others)

  • 5
    I have been using something like this for years, but it would be nice to hear from some windows gurus. I find it hard to believe that there is no "built-in" way to auto-mount network shares. Mar 15, 2013 at 2:25
  • 1
    A persistent mapped drive is the built in way to do it, but if there is no network connection at the instant it tries to mount it, it will be left in a disconnected state. This is usually the case with wireless networks, which are usually connected at a later stage of the login process.
    – askvictor
    Mar 15, 2013 at 6:43
  • @askvictor so if i have ethernet, will it automount?
    – agz
    Mar 19, 2013 at 0:59
  • 1
    No @agz. 5 years later it still doesn't
    – Guian
    Mar 14, 2018 at 13:45

I generally simply use a batch script which does a "dir" command on that share.

Open Notepad, and enter the following:

dir I:

Replace I with the drive letter you have mapped.

You can also do >nul on the end of that command to hide the output in the command prompt window when it runs.

Click File, then Save As.
Change Save as Type to All Files. Save the file in the C:\Users\username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup folder and call it mapdrive.bat. Replace username with your own username.

Next time you start your computer it will run this script. It will force windows to connect to the mapped drive.


A simple net use command is all that should be needed. If your network share requires a different username/password, those can be specified too.

net use i: \\server1\Directory3 /persistent:yes

Net Use docs:

I map shares like this all the time without issue. Sometimes it takes a moment or two after logging in for the share to reconnect. It's not always instant.


you can try using a batch file to copy a non-existent file from the mapped drive to the local c:\ drive. This would force the mapped drive to mount and look for the file, return an error, but the drive will be mounted.

A simple batch file in the startup group should do the trick -

copy :\badfile.txt c:\

Save as MOUNTME.BAT then put this in the startup folder.

  • Haha! My startup folder is on the network drive!
    – chuckkahn
    Aug 15, 2015 at 15:25

When you map the drive (In explorer) choose to map an internet (connect to a website to share your documents) and then map as usual. This is how we map our SAMBA shares and it maps on login. I have never delved into the differences between this method and the normal map method or between in and the normal net use x: \server\path method Our samba shares are off site and on network, and it works great...

The only other odd thing we have to do is enable NTLM v1 if v2 does not respond.


The following batch file looks at what drives you have mapped that are marked as "unavailable" or "disconnected" and then tries to map them again. The advantage of this approach is that you don't have to maintain a list of the drives you have mapped and it'll happily handle any drives you add (or remove) at a later date without modification:

@echo off
setlocal enabledelayedexpansion

for /f "tokens=2,3" %%a in ( 'net use ^| findstr /I  "unavailable disconnected"' ) do (
    net use %%a /delete
    net use %%a %%b
    rem Next line probably not essential, but doesn't seem to hurt
    dir %%a >nul

Whilst the above works just fine, I personally put this into a slightly more complicated script which first checks to see if you are actually on your home network before trying to map your drives.

To use the enhanced script, save the code below locally as automount.bat, make sure you set routermac correctly and then create a scheduled task to run it with the trigger to be "On workstation unlock".

@echo off
setlocal enabledelayedexpansion

rem automount.bat
rem Batch file which checks if you are running on your home network
rem and, if so, attempts to re-attach disconnected network drives.
rem --- Configuration options --------------------------------------------
rem routermac - The MAC address of the home router, used to determine
rem             whether or not the computer is at home. Get this by
rem             using "arp -a" from the command line and looking for
rem             the IP address of your router. 

set routermac=12-ab-34-cd-56-ef

rem --- Nothing to configure below here ----------------------------------

rem Pull the default gateways from ipconfig and extract the one with a value.
rem Carefull! There is 1 extra space before the ip-address.

for /L %%i in (1,1,10) do (
    timeout 2 

    for /f "delims=: tokens=2 usebackq" %%a in ( `ipconfig ^| find /I "default gateway"` ) do (
        if NOT "%%a."==" ." (
            set IP=%%a
            goto got_gateway

rem 10 attempts over 20 seconds and we still cannot find a default gateway,
rem so the computer probably isn't connected to any network

echo No gateway found after 20 seconds, giving up


rem Ping it to make sure it appears in arp -a output

echo Gateway is %IP%
ping -n 1 %IP% 

rem Filter the line with the ip-address and MAC from arp -a and take action if found

arp -a | find /I "%IP%" | find /I "%routermac%"
if errorlevel 1 (
    rem The mac address doesn't match the one we're looking for, so we're
    rem probably connected to a different network
    echo Internet connection found, but we are not at home

rem Get list of mapped drives marked as "unavailable" and then
rem re-mount them. It is unclear if running "dir" after mounting helps, but
rem it seems to do no harm.

for /f "tokens=2,3" %%a in ( 'net use ^| findstr /I  "unavailable disconnected"' ) do (
    net use %%a /delete
    net use %%a %%b
    dir %%a >nul

If you don't like the fact that a window is displayed when it runs then you have a number of options - the two easiest are below:

  1. Create a shortcut to the batch file, configure the shortcut to run minimised (right click on it and select "properties") and then call the shortcut instead from Task Scheduler. Only downside to this approach is that you'll see a brief flash on the task bar.
  2. Download something like nircmd and call that from your scheduled task as nircmd exe hide "c:\full\path\to\automount.bat"

If you connect to your home network via a VPN then you should be able to call this batch file once the connection is up, although I've not properly tested it.


Assuming you are using windows 7.

Click on "Computer", you will see "Map network drive" button on top. Click "Map network drive"

Select drive letter, enter your network folder path.

That's it.

  • 1
    The OP has asked for mounting the drive automatically on logon, not by doing it manually as you have mentioned!
    – Syed Waqas
    Mar 25, 2018 at 7:33
  • Yes, there is a check box "Reconnect at logon", just check on it.
    – Danny Hong
    Nov 21, 2019 at 9:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .