To check if mapped drive exist then delete/disconnect it:
if exist X: (net use /d /y X:)
similarly, for substituted drive:
if exist X: (subst /d X:)
however, you can't delete/disc a mapped drive using subst or vise versa, hence there is a need to check whether a drive was mapped or substituted, using:
net use | find " V: " >nul && (net use /d /y V:) || (subst /d V:) >nul