batch script to check for file mapping and remap if disconnected


The below script was set to check for a specific file mapping that was disconnecting. If detected it will then remap the drive.

Simply change the s part in s:null to your drive letter and then add in the Email and mapping details which are highlighted in caps with the hyphen (eg EMAIL-HERE)

if exist s:nul if exist map.lock del map.lock & goto END

if exist map.lock goto END

if exist s:nul goto END
else
print "drive not mapped"
blat -to "EMAIL-HERE" -server SMTP-HERE -f SERVER-HERE@root.com -subject "Mapping Failed" -body "drive Mapping Failed/disconnected"
echo & map.lock
net use s: \\DNS-ADDRESS-HERE\FOLDER-HERE
:END