Development‎ > ‎VBScript‎ > ‎

Map network drive


'*********************************************************************************
'* Function signature:
'* Description:
'*                  
'*
'* Parameters
'*
'*
'*
'* Return Value
'*
'*********************************************************************************
Sub MapNetworkDrive(sDriveLetter, sShare, sUsername, sPassword)
       Dim oWshNetwork
       Set oWshNetwork = WScript.CreateObject("WScript.Network")
       oWshNetwork.MapNetworkDrive sDriveLetter, sShare, "1", sUsername, sPassword
      
       'Clean up
       Set oWshNetwork = Nothing
End Sub

Here is usage example:
'Example usage
MapNetworkDrive "Z:", "\\192.168.0.200\shares", "mzaleski", "secret"

Comments