'VBS to connect and disconnect network drives.
'strPath and strDrive and the shared drive path and the drive letter to be mapped.
'Assumption is that the drive letter is valid and does not contain any drives mapped to it already.
'Commented line of code can be used to disconnet the mapped network drive.
Set objNetwork = CreateObject("Wscript.Network")
strPath = "\\test\test"
strDrive = "D:"
objNetwork.MapNetworkDrive strDrive ,strPath
'Use the code below to remove any network drive connections
Set objNetwork = Nothing