2

Is there a batch file/script that can be used to refresh a mapped network drive on Windows 7? The computer is currently hooked up to a mobile broadband connection (Novatel wireless MC551). The computer is a new station that is used for scanning paperwork and must be up 24/7. It has rebooted 2 twice in the past 2 weeks. During a restart Windows 7 trys to connect to that mapped drive right away and the wireless connection hasn't even been established yet. The only way to refresh the mapped drive is to click on it. So is there a batch can to a persistent refresh on that mapped drive?

2
  • I've found that applications can still use mapped drives even when they appear as 'disconnected', even though the network is fine ... For example, I have a mapped drive that has notepad++ documents, and when I open notepad++, they automatically open. If, for some reason when I start my computer, the drive appears as disconnected, these files still open in notepad++, but the drive will still have an x next to it Commented Jan 17, 2015 at 2:30
  • you could try to set the policies as outlined here: superuser.com/questions/328739/… as an alternative solution
    – wmz
    Commented Jan 17, 2015 at 8:27

3 Answers 3

2

if the issue only occurs when the client reboots, you can try to schedule a batch file to execute at login, containing something like

net use x: /delete
net use x: \\server\share\ /persistent:yes

if you want to delay it longer for other things to run, like the network connection startup, put a command at the top like sleep 10 (10 is the number of seconds you would like to wait).

you really need to get a more stable system-level network connection if you wish to use the machine as infrastructure as you say.

1
  • 1
    And if it doesn't only occur at boot, you could improve that batch file hugely by: 1. before you do the delete & reconnect, doing a check that tries to actively access the drive (like create a temp file). 2. writing a loop around it all that does it every minute.
    – SadBunny
    Commented Jan 17, 2015 at 3:30
1

The following batchfile shows how

  • to test a driveletter
  • to insert a delay of 10 seconds. (Windows 7 has no sleep or wait)
 @echo off
  rem test driveletter before usage of net command to prevent errormessages
 :loop
  if exist x:\. net use x: /del /yes
  if not exist x:\. net use x: \\server\share\ /persistent:yes
  choice /t 10 /d j >nul
  goto loop


In this example the line if exist x:\. net use x: /del /yes makes no sense and is destructiv!

-1
rem find drive status as "Disconnected"
net use Z: | find "Disconnected"
if %errorlevel% equ 1 goto end
rem change directory to drive causing a refresh
Z:
:end
rem drive status was not in a disconnected state
1
  • Perhaps you could describe what this code does, and how it is an answer to the question.
    – Berend
    Commented Aug 12, 2020 at 6:43

You must log in to answer this question.

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