VMWare workstation 让虚拟机随主机自动启动

本文介绍如何在Window和Linux上实现VMware虚拟机的自动启动。对于Window平台,可以通过创建批处理文件调用vmrun.exe来实现。而在Linux环境下,则可通过创建shell脚本来批量启动多个虚拟机,并提供了一个具体的示例脚本。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Window上:

How to autostart a virtual machine in VMware Workstation

 

 

Create a batch file with this line:
"C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe" -T ws start E:\VMs\wxp-a\wxp-a.vmx nogui
Replace wxp-a with the name of your virtual machine.
Call this batch from your windows startup menu.

 

Linux上:

Auto-Start Your VMWare Virtual Machines Without the GUI

Posted: 19th January 2011 by Mark in Unix
3

I was looking for a method that allowed me to SSH to my Linux machine running VMWare Workstation 7 and execute a file that automatically starts all my VMWare virtual machines without having to use the GUI.  This could also be used as a startup script as well.

In my case I am running several Cisco Unified Communications servers.  I also have a Windows 2008 VM to integrate LDAP with CUCM. I used vi to create a file called ciscostart.sh and made it executable. By executing this file I am able to start all VM’s without having to use the GUI.

#!/bin/bash
#
#Init file for starting Cisco virtual machines

vmrun start ~/vmware/CUCM_8_PUB/CUCM_8_PUB.vmx nogui
vmrun start ~/vmware/CUCM_8_SUB/CUCM_8_SUB.vmx nogui
vmrun start ~/vmware/UNITY_CONNECTION_8/UNITY_CONNECTION_8.vmx nogui
vmrun start ~/vmware/CUPS_8/CUPS_8.vmx nogui
vmrun start ~/vmware/EMERGENCY_RESPONDER_8/EMERGENCY_RESPONDER_8.vmx nogui
vmrun start ~/vmware/MEETING_PLACE_8/MEETING_PLACE_8.vmx nogui
vmrun start ~/vmware/UCCX8/UCCX8.vmx nogui
vmrun start ~/vmware/Win2008_Server_Primary_AD/Win2008_Server_Primary_AD.vmx nogui

To gracefully stop theese VM’s I created another file called ciscostop.sh and the arguments are very similar.

#!/bin/bash
#
#Init file for stopping Cisco virtual machines

vmrun stop ~/vmware/CUCM_8_PUB/CUCM_8_PUB.vmx soft
vmrun stop ~/vmware/CUCM_8_SUB/CUCM_8_SUB.vmx soft
vmrun stop ~/vmware/UNITY_CONNECTION_8/UNITY_CONNECTION_8.vmx soft
vmrun stop ~/vmware/CUPS_8/CUPS_8.vmx soft
vmrun stop ~/vmware/EMERGENCY_RESPONDER_8/EMERGENCY_RESPONDER_8.vmx soft
vmrun stop ~/vmware/MEETING_PLACE_8/MEETING_PLACE_8.vmx soft
vmrun stop ~/vmware/UCCX8/UCCX8.vmx soft
vmrun stop ~/vmware/Win2008_Server_Primary_AD/Win2008_Server_Primary_AD.vmx soft

 

With the Linux version of VMWare you can execute vmware instead of vmrun and it launches a new instance of vmware with the specific guest OS you specify. In fact, this was the default behavior and I wrote this blog post to work around that. I do not run vmware on Windows but I would like to think the same is achievable. You could most likely make a .BAT script that launches vmware from a DOS prompt and loads the vmware guest OS you want. Create a .BAT for each VM or maybe try combining all the commands into one .BAT if you always want to launch the same guests each time.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值