Resolve drive mapping issues with custom script

Share on facebook
Share on linkedin
Share on twitter
Share on google
By Cory Law-Davis

This week I dealt with a challenging issue involving a shared drive of one of our customers. The problem was that the drive would frequently disconnect itself at random intervals throughout the day, meaning the user consistently lost the ability to use their mapping software.

At first, I though it was a simple issue, like his VPN being disconnected. Upon accessing the customer’s device through remote tools, I found there was more to it. The VPN was connected, and the customer was having to continuously remap the drive himself. At first glance, I disconnected the drive and forced a GP update using:

gpupdate/ force 

After a day or two, I hadn’t heard back about the issue and decided to send a follow up email. The customer saying that the GP update solved the issue for a day, but it had since reoccurred. So I tried a different approach by creating a script to check for the drive and if it was missing, force map the drive. The script looked as follows:

@echo off

:start

Timeout /t 5 /nobreak >NUL

If exist X: \NUL goto End

Net use X:\192.168.xx.xx\Spatial_Data /User:domain\user /PERSISTENT:YES

If ERRORLEVEL 1 goto Start

:End

This script worked fine until I was told the customer’s mapping software was hard coded to use V: Drive not the mapped X: Drive. As a result, the script had to modified to read as V, and this finally resolved the customer’s issue.

@echo off

:start

Timeout /t 5 /nobreak >NUL

If exist V: \NUL goto End

Net use V:\192.168.xx.xx\Spatial_Data /User:domain\user /PERSISTENT:YES

If ERRORLEVEL 1 goto Start

:End

Our service desk offers a range of Level 1, 2 and 3 support to assist with any IT issues you may have. Learn more about our managed services here.

Leave a Reply