Automatically re-map disconnected network drives

At work, we provide kitchen automation software & hardware for some of the top quick service restaurants around the world.

One of the features of our software is providing Speed of Service reports for the managers to check on the performance of their staff.

One of our clients requested reports to be sent out from a centrally managed location. Each of the servers on site will have to generate & send reports to a mapped network drive to the central report server via VPN, and from there they are sent out to the individual area managers, store managers, accountants etc.

A common problem with good old Windows XP is a network disruption can cause a network drive to “disconnect” and would require you to manually double-click the drive in My Computer to re-connect it.

As there are hundereds of these restaurants, these network drive disconnections can be quite frequent, but are not monitored so it is up to the recipients of the reports to inform us that reports had not been sent through.

I figured out a quick simple fix to force a drive to reconnect at a regular interval using a Windows Scheduled Task.

The following code is very simple. Simply, it attempts to find a file on drive R: named donottouch.txt and rename the file extension from “.txt” to “.000”.

It then pings google.com. This is to simply give it a slight pause from the inital rename command, to moving on with renaming the extension back to “.txt”.

cd /d R:
ren donottouch.txt donottouch.000
ping google.com
ren donottouch.000 donottouch.txt

Now, the above is simply my preference. You would obviously need to create the donottouch.txt (a blank text document) in the mapped network drive.For a slightly easier setup (say if you were to mass deploy this file), you could simply get the batch file to create a temporary file on the mapped drive. You could even include error levels with some sort of email notification (using blat for example) if any issues were to arise.

Now for the scheduling, I set this to run every 20 minutes, every single day with the highest privileged  This is in case the user account gets logged out.

So far, 6 months down the line, I have had no problems with this and have not received any emails from concerned managers regarding missing reports!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.