Friday, July 11, 2014

UFT - Map Network Drive

If you want to map a network drive:


User = "domain\username"   ' the user name you want to use for mapping the network drive
    Password = "Password123"     'the password for the above user


    LocalDrive = "S:"        
    RemoteShare = "\\servername\FolderName"

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objNetwork = CreateObject("WScript.Network")

    'Unmap the drive (optional)
    If(ObjFSO.DriveExists(
LocalDrive)) Then
        objNetwork.RemoveNetworkDrive LocalDrive, TrueTrue
    End If

    'Map the drive command
    objNetwork.MapNetworkDrive LocalDrive, RemoteShare, True, User, Password

    Set objNetwork = Nothing
    Set objFSO = Nothing





No comments:

Post a Comment