Skip to main content

VMware 命令行操作虚拟机

· 2 min read
Alan

使用命令行 vmrun 操作虚拟机

note

Windows环境, vmrun 命令一般在 C:\Program Files\VMware\VMware Workstation\vmrun 或者 C:\Program Files\VMware\VMware Workstation\vmrun

macOS 或者 Linux 一般直接输入 vmrun 即可.

命令参数

命令格式: vmrun [AUTHENTICATION-FLAGS] COMMAND [PARAMETERS]

AUTHENTICATION-FLAGS
--------------------
These must appear before the command and any command parameters.

-T <hostType> (ws|fusion||player)
-vp <password for encrypted virtual machine>
-gu <userName in guest OS>
-gp <password in guest OS>



POWER COMMANDS PARAMETERS DESCRIPTION
-------------- ---------- -----------
start Path to vmx file Start a VM or Team
[gui|nogui]

stop Path to vmx file Stop a VM or Team
[hard|soft]

reset Path to vmx file Reset a VM or Team
[hard|soft]

suspend Path to vmx file Suspend a VM or Team
[hard|soft]

pause Path to vmx file Pause a VM

unpause Path to vmx file Unpause a VM
  • -T <hostType> 用于指定物理机使用vmware软件, ws 指的是 VMware Workstation, Windows和Linux物理机安装的是这个. VMware Fusion 是macOS使用的, player 仅指 VMWare Player(Windows, Linux和macOS都可以安装).

基础命令

列出运行的虚拟机

vmrun list

Total running VMs: 1
/data/vmware/windows7/windows7x64.vmx

启动虚拟机

vmrun -T ws start "/data/vmware/windows7/windows7x64.vmx"

关闭虚拟机

vmrun -T ws stop "/data/vmware/windows7/windows7x64.vmx"

vmware tools

vmrun installtools "/data/vmware/windows7/windows7x64.vmx"
vmrun checkToolsState "/data/vmware/windows7/windows7x64.vmx"

删除虚拟机

vmrun deleteVM "/data/vmware/windows7/windows7x64.vmx"

开启文件夹共享

vmrun -T ws enableSharedFolders "/data/vmware/windows7/windows7x64.vmx"