The command‐line examples that follow work on Workstation (-T ws) and VMware Fusion (-T fusion). You can derive the guest operating system type in examples by distinguishing / for Linux and \ for Windows.

Reviewers: djohn Mon Nov 6 11:11:05 PST 2017

The introduction above should probably be specific to VMware Fusion, such as the following:

The command-line examples that follow are specific to VMware Fusion (-T fusion). You can derive the guest operating system type in examples by distinguishing / for Linux and \ for Windows.

Reviewers: djohn Mon Nov 6 14:47:39 PST 2017

Please review all of the commands carefully and tell me if any of the commands are not displayed properly. Also, suggest changes if you feel something is out of date. For example, Windows XP is in examples, but the examples should probably refer to something newer. The same applies to Linux versions. For example, should I replace RHEL4 with something newer? Or Ubuntu10 with something newer?

Reboot Commands

  • Reboot a virtual machine running on Workstation for Linux.

    Reviewers: djohn Mon Nov 6 11:14:03 PST 2017

    I assume we'll drop all commands for Workstation, correct?

    vmrun -T ws reset /path/to/vm/RHEL4/RHEL4.vmx soft
  • Reboot a virtual machine running on Workstation for Windows.

    cd "C:\Documents and Settings\<user>\My Documents\My Virtual Machines" vmrun -T ws reset "WindowsXP\WindowsXP.vmx" soft
  • Reboot a virtual machine running on Fusion.

    Reviewers: djohn Mon Nov 6 12:34:21 PST 2017

    Can we change the commands above and below from WindowsXP to something else since XP is so old?

    vmrun -T fusion reset ~/Documents/VirtualMachines.localized/WindowsXP.vmwarevm/WindowsXP.vmx soft

Snapshot Commands

  • Create a snapshot of a virtual machine with Workstation on a Linux host or Fusion.

    Reviewers: djohn Mon Nov 6 12:54:50 PST 2017

    Can I delete "Workstation on a Linux host or" from the sentence above? The can I make everything below Fusion specific? How? Just change all instances of "-T ws" to "-T fusion"?

    vmrun -T ws snapshot /path/to/vm/Ubuntu/Ubuntu.vmx mySnapshot
  • List snapshots on the virtual machine, showing the one made in the previous command.

    vmrun -T ws listSnapshots /path/to/vm/Ubuntu/Ubuntu.vmx
    Total snapshots: 1
    mySnapshot
  • Revert to the snapshot you made, which suspends the virtual machine, and restart to resume operation.

    vmrun -T ws revertToSnapshot /path/to/vm/Ubuntu/Ubuntu.vmx mySnapshot
    vmrun -T ws start /path/to/vm/Ubuntu/Ubuntu.vmx
  • Delete the snapshot by specifying its name.

    vmrun -T ws deleteSnapshot /path/to/vm/Ubuntu/Ubuntu.vmx mySnapshot

Network Adapter Commands

  • Reviewers: djohn Tue Nov 7 13:55:55 PST 2017

    Can you provide examples of Network Adapter Commands?

Host Network Commands

  • Reviewers: djohn Tue Nov 7 13:55:55 PST 2017

    Can you provide examples of Host Network Commands?

Running Guest Applications

Most vmrun guest operations require VMware Tools to be installed on the guest operating system.

Reviewers: djohn Mon Nov 6 14:31:26 PST 2017

Please advise how to make this all applicable to Fusion.

  • Start the command tool, minimized, on a Windows guest.

    vmrun -T ws -gu user runProgramInGuest WinXP\WinXP.vmx cmd.exe
    Guest password: pass
  • Start the command tool on a Windows guest as an active window on the desktop,

    vmrun -T ws -gu user runProgramInGuest WinXP\WinXP.vmx -activeWindow cmd.exe
    Guest password: pass
  • Run a batch script file on a Windows guest, with Perl as the script interpreter.

    vmrun -T ws -gu user runScriptInGuest Win2k\Win2k.vmx C:\perl\perl.exe C:\script.pl
    Guest password: pass
  • Run a batch script and keep running afterwards. To use cmd.exe on Windows, you must specify the script interpreter as null.

    vmrun -T ws -gu user -gp pass runScriptInGuest WindowsXP\WindowsProfessionalXP.vmx ""
    "cmd.exe /k \"C:\\Program Files\\Microsoft Visual Studio\\VC\\vcvarsall.bat\" x86"

  • Run a Bash shell script called runit on a Linux guest.

    vmrun -T ws -gu user -gp pass runScriptInGuest Ubuntu/Ubuntu.vmx /bin/bash /home/<user>/runit
  • Start an X clock on a Linux guest, which requires the -display option to appear on the console.

    vmrun -gu user -gp pass runProgramInGuest SUSE/SUSE.vmx /usr/bin/xclock -display :0
  • Run the same X clock command, but return control back to the console immediately.

    vmrun -gu user -gp pass runProgramInGuest SUSE/SUSE.vmx -noWait /usr/bin/xclock -display :0
  • New versions of Firefox support the--display flag from X11, so the option looks a bit different.

    Reviewers: djohn Tue Nov 7 11:56:14 PST 2017

    The sentence above probably has to change. I don't even know what it's saying. Does it relate to X clock also? Since this comes from a document that is more than five years old, saying "New versions" might not be accurate anymore. Is it?

    vmrun -gu user -gp pass runProgramInGuest Ubuntu/Ubuntu.vmx /usr/bin/firefox --display=:0
  • For commands that require an environment variable, you can set it first or export it for multiple commands.
    Reviewers: djohn Tue Nov 7 12:08:54 PST 2017

    What does this mean?

    Does it mean the following?:

    For commands that require an environment variable, you can set it first as demonstrated by the first example that follows or you can export it for multiple commands as demonstrated by the second example that follows.

    vmrun -gu user -gp pass runProgramInGuest SUSE/SUSE.vmx "DISPLAY=:0 /usr/bin/salesgui"
    
    vmrun -gu user -gp pass runProgramInGuest SUSE/SUSE.vmx "export REL=7; /opt/cmd1; /opt/cmd2"
  • Setting the guest environment with guestEnv parameter requires root permission on Linux because the change affects subsequent commands issued by other users.

    vmrun -T ws -gu root -gp rootpass writeVariable SUSE/SUSE.vmx guestEnv SRC tmp.example.com:1666
  • List processes in a Linux guest and end the process numbered 8192.

    vmrun -T ws -gu user -gp pass listProcessesInGuest Ubuntu/Ubuntu.vmx
    
    vmrun -T ws -gu user -gp pass killProcessInGuest Ubuntu/Ubuntu.vmx 8192
  • Run a Perl script on a Linux guest to remove DOS-style carriage returns from a file.

    Reviewers: djohn Wed Nov 8 08:43:36 PST 2017

    Please let me know if the next two commands are presented properly.

    vmrun -T ws -gu user -gp pass runProgramInGuest Ubuntu/Ubuntu.vmx /usr/bin/perl -e
    "open(FILE, '>/tmp/unix.txt'); while (<>) { s/\r\n/\n/ ; print FILE}" /tmp/dos.txt
  • Run a Perl script on a Windows guest to insert DOS-style carriage returns in a file.

    vmrun -T ws -gu user -gp pass runProgramInGuest WinXP\WinXP.vmx C:\cygwin\bin\perl.exe -e
    "open(FILE, ‘>C:\dos.txt’); while (<>) { s/\n/\r\n/ ; print FILE}" C:\unix.txt
  • Run a program in a Linux virtual machine on an ESXi host.

    Reviewers: djohn Tue Nov 7 12:36:38 PST 2017

    The sentence above said "ESX/ESXi." I changed it to just "ESXi". Let me know if that's correct. Also, let me know if the code is correct with esx in it.

    vmrun -T esx -h 10.0.1.8 -u root -p pass -gu user -gp userpass runProgramInGuest

Guest to Host File Operations

  • To copy a file from the host to a guest, the user must have write permission on the destination.

    vmrun -gu user -gp pass copyFileFromHostToGuest Ubuntu\Ubuntu.vmx C:\Temp\img.db /tmp/img.db
  • To copy a file from a guest to the host, the user must have read permission on the source file.

    vmrun -gu user -gp pass copyFileFromGuestToHost Ubuntu\Ubuntu.vmx /home/<user>/addr addr.txt
  • To share a folder on a Windows host with a particular Linux guest.

    Reviewers: djohn Wed Nov 8 10:03:55 PST 2017

    I moved this description around. For example, I made the description below a "Note" and I moved it below the explanation that is now above. I didn't check the interface description below. Is it right for the Fusion user interface? Can I simply change "-T ws" to "-T fusion"

    Note:

    Before sharing folders, you must enable them with the enabledSharedFolders option, or by selecting VM > Settings > Options > Shared Folders > Enabled in the user interface. On Linux guests, the /mnt/hgfs directory is available for sharing, but you can use a different directory for shared folders.

    vmrun -T ws addSharedFolder Ubuntu\Ubuntu.vmx sharedFolderName C:\Share
  • To make a shared folder read‐only or to delete the shared folder.

    Note:

    Shared folders are writable by default.

    vmrun -T ws setSharedFolderState Ubuntu\Ubuntu.vmx sharedFolderName C:\Share readonly
    
    vmrun -T ws removeSharedFolder Ubuntu\Ubuntu.vmx sharedFolderName
    Note:

    Reviewers: djohn Wed Nov 8 10:21:36 PST 2017

    Is the following note talking about Windows 7 and Vista hosts? So can I delete the note for Fusion?
    On Windows 7 and Vista, only the Administrator account can use copyFileFromHostToGuest and deleteFileInGuest options to write and delete files in the C:\ and system folders, or use the createDirectoryInGuest and deleteDirectoryInGuest options to modify system directories. Regular users, even those with administrator privilege, cannot perform these operations.

Guest Variables and Environment

  • From the host, set a guest variable on two virtual machines.

    vmrun writeVariable WindowsXP/WindowsXP.vmx guestVar vmstartdate 21April2017
    vmrun writeVariable Ubuntu10/Ubuntu10.vmx guestVar vmstartdate 21April2017 
  • On the guest operating systems, read the guest variable that you just set.

    Reviewers: djohn Wed Nov 8 08:38:33 PST 2017

    In the old vmrun guide, the following command is listed on two lines. Is it okay to present the command on one line?

    >  vmware-rpctool.exe "info-get vmstartdate"  
    $  vmware-rpctool "info-get vmstartdate"
  • From the host, set a guest environment variable on a Linux virtual machine and verify by writing the environment variables into a temporary file.

    vmrun writeVariable Ubuntu10/Ubuntu10.vmx guestEnv LD_LIBRARY_PATH /usr/local/lib
    Guest user: root
    Guest password:
    vmrun runScriptInGuest Ubuntu10/Ubuntu10.vmx /bin/bash "usr/bin/env > /tmp/env.out"
    Guest user: root
    Guest password:
    Note:
    No output is sent to the host when you use the runScriptInGuest option with the vmrun command. Find the output of the command in the /tmp/env.out file on the guest.
    Reviewers: djohn Tue Nov 7 14:39:35 PST 2017

    I don't know if I understand what the original sentence that I rewrote above is supposed to mean. Here is the original sentence:

    "No output comes to the host from runScriptInGuest, so look at /tmp/env.out on the guest."

    Is "/tmp/env.out" an example or is it always the name of the file? If it's just an example, I'd prefer to write "Find the output of the command in the temporary file that you provided, which in this example is the '/tmp/env.out' file."

    From a technical writing point of view, I feel the need to say what things are, such as "option" and "file". Therefore I said, " the runScriptInGuest option" and the "/tmp/env.out file." Please let me know if "option" and "file" are the correct nouns to use in these cases.

  • On a Linux guest, determine the IP address and set it in a guest variable.

    Reviewers: djohn Wed Nov 8 08:42:17 PST 2017

    Is it okay to leave the following command on two lines as it was in the guide?

    $ ipaddr=‘ifconfig eth0 | grep inet.addr‘
    $ vmware-rpctool "info-set guestinfo.ip $ipaddr"
  • From the host, retrieve the IP address that was just set to the guest.

    vmrun readVariable Ubuntu10/Ubuntu10.vmx guestVar guestinfo.ip

General Commands

  • List running virtual machines on Workstation.

    Reviewers: djohn Wed Nov 8 10:57:59 PST 2017

    Can this be done on Fusion?

    vmrun -T ws list
    Total running VMs: 2
    C:\Documents and Settings\user\My Documents\My Virtual Machines\Ubuntu\Ubuntu.vmx
    C:\Documents and Settings\user\My Documents\My Virtual Machines\Windows7\Windows7.vmx
  • Prepare to install VMware Tools on Fusion.

    vmrun -T fusion installTools RedHatEnt5/RedHatEnt5.vmx
  • Reviewers: djohn Wed Nov 8 11:02:26 PST 2017

    Are there any other general commands we should provides examples for?

The Template Virtual Machine Commands

Reviewers: djohn Tue Nov 7 13:55:55 PST 2017

Can you provide examples of Template Virtual Machine Commands?