CopyFileFromHostToGuest - INTERNAL ERROR: A file was not found

May 25, 2010 at 5:36 PM

Hey, I am trying to Copy files into a VMWare image hosted in ESX using VIX (C# Wrapper around the COM API), but I can't quite get it right.

Conceptual Something like:

IVMWareVirtualHost host = new VMWareVirtualHost();
host.ConnectToVMWareVIServer("172.18.19.69", "ESX Admin User", "ESX Admin Password");

IVMWareVirtualMachine virtualMachine = host.Open("Storage1 Image/Image.vmx");
virtualMachine.PowerOn();
virtualMachine.WaitForToolsInGuest();
virtualMachine.LoginInGuest("Administrator", "ILoveOMSIS!1234");
virtualMachine.CopyFileFromHostToGuest("C:\\temp
File.txt", "C:\\package
File.txt");

And it fails at the last line with "INTERNAL ERROR: A file was not found"...

The File exists Locally, Casing is corrent and the "C:\package" folder exists in the Guest.

Host System: ESX 4.0
Guest System: Windows XP
Client System: Windows 2003 server

(Client System refers to the system where I try tu run the commands and vmrun.exe

After trying to find some help ect on the web, I went to "vmrun" and tested a command that used to work with the "VMWare Server"

vmrun -T server -h https://localhost:8333/sdk -u "Local Admin User" -p "Local Admin Password" -gu "Guest Admin account" -gp "Guest Admin password" CopyFileFromHostToGuest "Standard Image/Image.vmx" "C:\temp\file.txt" "C:\package\file.txt"

changed to:

vmrun -T server -h https://172.18.19.69/sdk -u "ESX Admin User" -p "ESX Admin Password" -gu "Guest Admin account" -gp "Guest Admin password" CopyFileFromHostToGuest "Storage1Image/Image.vmx" "C:\temp\file.txt" "C:\package\file.txt"

Both Works just fine...

So what am I'm doing wrong in the code?

Coordinator
May 28, 2010 at 8:04 PM

I (re)tested this and it worked as expected. You probably didn't copy-paste the exact code above - are you sure you have to double-slashes in your file name after the path - c:\\temp\\file.txt - or declare it as @"c:\temp\file.txt".

Jun 17, 2010 at 12:58 PM
Edited Jun 17, 2010 at 1:13 PM

110% sure.

What API version are you using and what are you testing it up against?

There is some small "errors" in the command line arguments however, what i have tested is -T esx as well for the later command.

Coordinator
Jun 17, 2010 at 2:05 PM
Edited Jun 17, 2010 at 2:07 PM

I tested against ESX 3.5 and ESX 4.0 with VixCOM 1.8.1. Lets do this: write something without VMWareTasks, just by using the raw VixCOM API. Let's see which exact call returns what error message and what parameters are passed to it and whether it's a driver/ESX problem rather than VMWareTasks.

Aug 25, 2010 at 10:41 PM

I too am getting an error trying to use the CopyFileFromHostToGuest, my code follows, not sure if i could make it more bullet proof.  Also i'm  a noob with the VMWare Lib you have, seems pretty nice so far, i've been able to get most everything else i need working just fine.  

/* my code snippet...  */

String srcFile =  "c:\\testfile.txt";
string destFile = "c:\\testfile.txt";
if( System.IO.File.Exists(srcFile) )
{
    virtualMachine.CopyFileFromHostToGuest(srcFile,destFile);           
}

 

Machine Vitals:
-----------------
VMWare:   7.1.0 build-261024
VixCOM.dll:    1.9.0.12623   (5/20/2010)

 

Thanks in advance for any help,

 

dan d;)

 

 

 

 

 

Coordinator
Aug 26, 2010 at 12:23 PM

See http://communities.vmware.com/message/1539993#1539993, there're a few next steps described in the reply. Post what you find here.

Nov 30, 2010 at 11:38 AM

Hello,

did you find was was wrong here ?

I believe I have the same issue, using the java wrapper. ( ESX 4, VixCOM 1.8.1 )

ivm.loginInGuest(login, pass);  -> ok
ivm.copyFileFromGuestToHost("c:\\tmp\\test.txt", "d:\\tmp\\test.txt"); -> ok :file created on the host
ivm.createDirectoryInGuest("c:\\tmp\\mydir"); -> ok : folder created on the guest


ivm.copyFileFromGuestToHost("d:\\tmp\\test.txt", "c:\\tmp\\test2.txt"); -> error

 

Exception in thread "main" com4j.ComException: 80131500 (Unknown error) :A file was not found : .\invoke.cpp:460 at com4j.Wrapper.invoke(Wrapper.java:122) at $Proxy7.copyFileFromGuestToHost(Unknown Source) at com.ebay.spine.vmware.services.DelMe.main(DelMe.java:17)Caused by: com4j.ComException: 80131500 (Unknown error) : A file was not found : .\invoke.cpp:460 at com4j.Native.invoke(Native Method) at com4j.StandardComMethod.invoke(StandardComMethod.java:95) at com4j.Wrapper$InvocationThunk.call(Wrapper.java:258) at com4j.Task.invoke(Task.java:44) at com4j.ComThread.run0(ComThread.java:149) at com4j.ComThread.run(ComThread.java:125)

 

thanks,

françois

Nov 30, 2010 at 5:14 PM
If i remember correctly I switched to using a mapped drive in the VM and used the mapped drive path when referencing the file, that was the only reliable way i got around the error.
Dec 1, 2010 at 9:54 AM

@freynaud 

We ended discarding the "Vix-Wrappers" completely and revert back to using vmrun for all except snapshots since that didn't work with vmrun.

For that we wrapped that particular command our self.

I did succeed in wrapping the Copy in and out of the Guest my self using the COM api, but I could never figure the difference in this API and what I did... so couln't post a fix back.

Haven't looked at it since.

Coordinator
Dec 1, 2010 at 12:24 PM

@freynaud: get VMWareTasks source code and write a simple unit test repro in C# - I am sure we can fix it easily with that - I tried with my ESX servers and code similar to yours worked just fine.

Coordinator
Dec 3, 2010 at 1:33 AM
freynaud wrote:

Hello,

did you find was was wrong here ?

I believe I have the same issue, using the java wrapper. ( ESX 4, VixCOM 1.8.1 )

ivm.loginInGuest(login, pass);  -> ok
ivm.copyFileFromGuestToHost("c:\\tmp\\test.txt", "d:\\tmp\\test.txt"); -> ok :file created on the host
ivm.createDirectoryInGuest("c:\\tmp\\mydir"); -> ok : folder created on the guest


ivm.copyFileFromGuestToHost("d:\\tmp\\test.txt", "c:\\tmp\\test2.txt"); -> erro

Uh, shouldn't this last line be copyFileFromHostToGuest (d:\\tmp\\test.txt exists on the host, not onthe guest)?

Developer
Oct 11, 2011 at 10:51 PM

I think the problem here is that you need to explicitly create the directory in the guest before copying files into it.