VMware Guest - Copy file

Declaration

<AMVMWAREGUEST HOSTTYPE="Server" SERVER="text" USERNAME="text" PASSWORD="text (options)" VMPATH="text" GUESTUSERNAME="text" CONSOLE="YES/NO" LAUNCHGUI="YES/NO" TIMEOUT="number" GUESTPASSWORD="text (options)" OPENVMTIMEOUT="number" POWERONTIMEOUT="number" TOOLSTIMEOUT="number" LOGINTIMEOUT="number" CONNECTIONTIMEOUT="number" COPYFROM="text (options)" GUESTFILE="text" HOSTFILE="text" />

Related Topics   

Description

Copies a file or directory from the guest operating system to the local system or copies a file or directory from the local system to the guest operating system.

NOTE: All functions that execute in a guest operating system require VMware Tools to be installed and running. Additionally, a valid guest login is required to run this activity.

Practical usage

Used to copy a file or folder to or from the guest OS. The format of the file name depends on the operating system. For example, a path name for a Microsoft Windows guest or host requires backslash as a directory separator, whereas a Linux guest or host requires a forward slash. If the path name includes backslash characters, you need to precede each one with an escape character.

Parameters

Connection

Property Type Required Default Markup Description
Connection --- --- --- --- Indicates where connection details, guest credentials and other preferences should originate from. The available options are: The available options are:
  • Host (default) - Connection details, guest credentials and other preferences are configured individually for this activity. Select this option if only a single activity is required to complete an operation.
  • Session - Connection details, guest credentials and other preferences are obtained from a session created in a previous step with the use of the WMware Guest - Connect activity. Select this option if a combination of activities within the same action group are required to complete an operation. Linking several activities to a single session eliminates redundancy and improves efficiency. Several sessions can exist in a single task. Multiple sessions can run simultaneously without interference.
NOTE: This parameter does not contain markup and is only displayed in visual mode for task construction and configuration purposes.
Session Text Yes, if Connection is set to Session GuestOSOpsSession1 SESSION="MySession" The name of an existing session to associate this activity with. This parameter is available only if the Connection parameter is set to Session.
Host type Text (options) Yes if Connection set to Host VMWare VI Server
  • HOSTTYPE="Server"
  • HOSTTYPE="Workstation"
  • HOSTTYPE="VIServer"
  • HOSTTYPE="Player"
Indicates the VMware software type running on the host where the virtual machine is located. If you are using VMware Server to connect to a remote host, it does not matter which VMware product (if any) is running on the local host. This parameter is available only if the Connection parameter is set to Host. The available options are:
  • VMWare Server (1.0x)
  • VMWare Workstation
  • VMWare VI Server (ESX/ESXi, vCenter, VMWare Server 2.0)
  • VMWare Player
Host name Text Yes (Empty)
  • SERVER="host.server.com"
  • SERVER="xxx.xxx.xxx.xxx"
The hostname or IP address of the computer where the virtual machine is located. This parameter is active only if the Host type parameter is set to VMWare Server (1.0x) or VMWare VI Server (ESX/ESXi, vCenter, VMWare Server 2.0).
[Host] Username Text Yes (Empty) USERNAME="theUser" The username identifying a valid user account on the virtual machine. This parameter is active only if the Host type parameter is set to VMWare Server (1.0x) or VMWare VI Server (ESX/ESXi, vCenter, VMWare Server 2.0).
[Host] Password Text Yes (Empty) PASSWORD="encrypted" The password identifying a valid user account on the virtual machine. This parameter is active only if the Host type parameter is set to VMWare Server (1.0x) or VMWare VI Server (ESX/ESXi, vCenter, VMWare Server 2.0).
Virtual machine path Text Yes (Empty) VMPATH="c:\My Virtual Machines\<vm_name>.vmx" The path to the virtual machine. (Example: c:\My Virtual Machines\<virtual_machine_name>.vmx ).
[Guest Credentials] Username Text Yes (Empty) GUESTUSERNAME="user" The username to authenticate the guest user.
[Guest Credentials] Password Text Yes (Empty) GUESTPASSWORD="encrypted" The password to authenticate the guest user.
Log on to console session Yes/No No No CONSOLE="yes" If selected, the user will be logged onto the console session. This parameter is disabled by default.
Launch GUI Yes/No No No LAUNCHGUI="yes" If selected, a GUI (Graphic User Interface) will appear on the desktop upon connection. If disabled (default), no GUI will be launched and operations will execute in the background.

Connection - Host > Timeout

Property Type Required Default Markup Description
Open VM Number No 60 OPENVMTIMEOUT="2" The maximum time period in seconds during which this activity must be completed or the step times out. The default value is 60 seconds.
Power on Number No 60 POWERONTIMEOUT="3" The maximum time period in seconds during which the VM must power on or the step times out. The default value is 60 seconds.
VMware tools Number No 300 TOOLSTIMEOUT="4" The maximum time period in seconds during which VMWare Tools must start on the guest operating system or the step times out. The default value is 300 seconds.
Log on Number No 60 LOGINTIMEOUT="5" The maximum time period in seconds during which the log on process must be completed or the step times out. The default value is 60 seconds.
Connection Number No 60 CONNECTIONTIMEOUT="6" The maximum time period in seconds during which a connection must be established or the step times out. The default value is 60 seconds.

Guest OS Operations

Property Type Required Default Markup Description
Copy file from Text (options) Yes Host to Guest
  • COPYFROM="guest_to_host"
  • COPYFROM="guest_to_host"

Indicates where the file or directory to copy originates from and where it should be copied to. The available options are:

  • Host to guest (default) - The file/directory will be copied from the host machine to the guest machine.
  • Guest to host - The file/directory will be copied from the guest machine to the host machine.
Host/Guest file path Text Yes (Empty)
  • HOSTFILE="C:\foldername\filename.jpg"
  • GUESTFILE="C:\foldername\filename.jpg"
The path and file name of the file or directory you wish to copy. If the Copy file from parameter is set to the option Host to guest, this parameter indicates Host file path. If the Copy file from parameter is set to the option Guest to host, this parameter indicates Guest file path.
NOTE: The format of the file name depends on the operating system.
Host/Guest file path Text Yes (Empty)
  • GUESTFILE="C:\foldername\filename.jpg"
  • HOSTFILE="C:\foldername\filename.jpg"
The path and file name in which to copy the file/directory to. If the Copy file from parameter is set to the option Host to guest, this parameter indicates Guest file path. If the Copy file from parameter is set to the option Guest to host, this parameter indicates Host file path.
NOTE: The format of the file name depends on the operating system.
Timeout (seconds) Number No (Empty) TIMEOUT="20" The maximum time period in seconds during which this activity must be completed or the step times out.

Description

Error Causes

On Error

Example

NOTE:
  • Copy and paste the sample AML code below directly into the Task Builder Steps Panel.
  • To successfully run the sample code, update parameters containing user credentials, files, file paths, or other information specific to the task to match your environment.

Description

This sample task uses several VMware Guest OS activities. It creates a session using the VMware Guest - Connect activity, logs onto the guest VMware using the VMware Guest - Log on activity, and checks if a specific guest file exists on the host using the VMware Guest - File exists activity. If the guest file exists, it is copied over to the host machine using the VMware Guest - Copy activity. The task ends with a VMware Guest - Disconnect step. Comments are included in the task to explain each step.

Copy
<AMVARIABLE NAME="myVar" VALUE="" />
<!-- Create a guest session. -->
<AMVMWAREGUEST ACTIVITY="connect" HOSTTYPE="Workstation" VMPATH="C:\Users\Username\Documents\Virtual Machines\Windows Server 2008 x86\Windows Server 2008 (experimental).vmx" GUESTUSERNAME="Techsupport" GUESTPASSWORD="AM1ag7WmWg7U1xbulaHHhbEOLvMrSDiPrC4aME" CONSOLE="yes" LAUNCHGUI="yes" OPENVMTIMEOUT="90" POWERONTIMEOUT="90" />
<!-- Log onto guest. -->
<AMVMWAREGUEST ACTIVITY="login" LOGINUSERNAME="Techsupport" LOGINPASSWORD="AM1ag7WmWg7U1xbulaHHhbEOLvMrSDiPrC4aME" LOGINCONSOLE="yes" TIMEOUT="3000" />
<!-- Check if a specific guest file exists. -->
<AMVMWAREGUEST ACTIVITY="file_exists" GUESTFILE="C:\Users\techsupport\Desktop\hello.txt" RESULTVARIABLE="myVar" />
<!-- If guest file exists, copy it over to the host machine. -->
<AMIF EXPRESSION="%myVar% = True"><AMVMWAREGUEST COPYFROM="guest_to_host" GUESTFILE="C:\Users\techsupport\Desktop\hello.txt" HOSTFILE="C:\Users\techsupport\Desktop\hello.txt" /></AMIF>
<AMVMWAREGUEST COPYFROM="guest_to_host" GUESTFILE="C:\Users\techsupport\Desktop\hello.txt" HOSTFILE="C:\Users\techsupport\Desktop\hello.txt" />
<AMIF ACTIVITY="end" />
<!-- Close Connection -->
<AMVMWAREGUEST ACTIVITY="disconnect" />