Not able to copy a file to shared folder which is located in another vm though it is accessible
Hi
i am trying to copy a file to a shared folder which is located in another vm but my below script is failing. Later i tried with Ranorex tool for the same and i am able to do that. Please suggest how to copy that file.
'======================================================
Dim sSourceFilePath
sSourceFilePath = "C:\Files\Test.txt"
If AddNetworkDrive("\\compname\c$\destination_Folder","Z") Then
Log.Message("Network Drive mapped")
call oFSO.CopyFile(sSourceFilePath,"Z:\",true)
If oFSO.FileExists ("Z:\Test.txt") Then
Log.Message("File Copied")
else
Log.Error("File not Copied")
end if
Else
Log.Message("Network Drive not mapped")
End if
Function AddNetworkDrive(sPath , sDriveLater)
dim sUserName,sPWD,res
sUserName = "domain\userid"
sPWD = "********"
Set oFSO = CreateObject("scripting.filesystemobject")
Set oWshNetwork = CreateObject("WScript.Network")
If Not oFSO.DriveExists("Z:") Then
'aDD USER NAME AND PASSWORD
'=========
res = aqFileSystem.MapNetworkDrive(sDriveLater, sPath)
If res <> 0 Then
Log.Error(aqUtils.SysErrorMessage(res) & " Error code is " & res & ".")
Else
Log.Message("The connection to '" & path & "' has been established successfully.")
End If
'========
If Not oFSO.DriveExists("Z:") Then
Log.Error("Network Drive not Added")
bFound = False
Else
Log.Message("Network Drive Added")
bFound = True
End If
Else
Log.Message("Netowrk Drive exists")
'bFound = True
Set oDrives = oWshNetwork.EnumNetworkDrives
For i = 0 to oDrives.Count - 1 Step 2
If oDrives.Item(i) = sDriveLater &":" Then
sUNC = LCase(oDrives.Item(i+1))
End If
Next
If sUNC = LCase(sPath) Then
bFOund = True
Else
'oWshNetwork.RemoveNetworkDrive sDriveLater &":", True
If Not oFSO.DriveExists("Z:") Then
Log.Error("Network Drive not Added")
bFound = False
Else
Log.Message("Network Drive Added")
bFound = True
End If
End If
End IF
AddNetworkDrive = bFound
End Function