Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


June 2004

VMware—At Your Service!

Run VMware Workstation VMs as services
RSS
Subscribe to Windows IT Pro | See More Products / Software Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

If you're a VMware enthusiast, you've probably on more than one occasion wanted to log off from your computer while leaving your virtual machines (VMs) running. Or, maybe you've wanted selected VMs to start as soon as your system boots so that your host system can log on to a domain controller (DC) running inside one of the host machine's VMs. Sound too good to be true? That's what I thought. I assumed that logging off of my computer and having my VMs remain running was an unattainable dream. But I discovered that getting VMs to run as services is possible and very easy to configure.

Tools for Service
VMware doesn't natively support running its software as a service, but configuring VMware Workstation 4.0 VMs to run as services is almost as easy as tying your shoes. All you need to get started are two tried-and-true Windows resource kit tools: instsrv.exe and srvany.exe. Both tools are available as free downloads. Go to http://www.microsoft.com/downloads, enter Windows 2003 Resource Kit Tools in the Keywords field, and click Go. Then, click the Windows Server 2003 Resource Kit Tools Download button at the Windows Server 2003 Resource Kit Tools Web page to download rktools.exe—which contains the most recent versions of Instsrv and Srvany—and run the executable to install the tools on your system.

Note that you can install the Windows 2003 resource kit tools on a Windows 2003 or Windows XP system. If your host system runs Windows 2000 or Windows NT, you can acquire Instsrv and Srvany from the Win2K or NT resource kit CD-ROMs or you can install the Windows 2003 resource kit tools on an XP system and just copy Instsrv and Srvany from the XP system to the %windir% folder on your Win2K or NT host system. The Windows 2003 versions of Instsrv and Srvany run on the earlier OSs without any problems.

Getting Started
Installing the resource kit tools updates the system path to include the resource kit installation folder. Updating the path requires a reboot, so be sure to reboot your system after installing the resource kit. Alternatively, you can copy Instsrv and Srvany to a folder already in the path, such as the folder C:\windows\system32.

With the resource kit files in place, your next task is to determine the location of the VMware application's vmware.exe file. I used the default settings when installing VMware, so the path I needed was C:\program files\vmware\vmware workstation\vmware.exe.

The last bit of information that you need before you configure the new service is the path to the configuration file of the VM that you want to turn into a service. This file is in the folder in which the VM was created and has a .vmx extension. All my VMs are stored on my system's E drive, so the path to the .vmx file of the VM that I want to run as a service is E:\vms\w2k1\w2k1.vmx. When you have the vmware.exe path and a VM's .vmx path information, you're ready to create the service.

Creating the Service
First, decide on a name for the service. I prefer to preface the name of the VM with VM_ to form the service name. For example, I would give my VM named W2K1 the service name VM_W2K1. After you decide on the service name, you can use the following syntax to set up the service:

instsrv <VM service name>
  <Srvany path>

So a sample command might be

instsrv VM_W2K1
  c:\windows\srvany.exe

Now you need to modify the service's parameters by using a registry editor and the Microsoft Management Console (MMC) Windows Services snap-in. In the registry editor, navigate to the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\<VM service name> subkey. Right-click the VM service name, select New, then click Key. Name the new subkey Parameters.

Right-click the Parameters subkey, select New, then click String Value. Name the new value Application. Double-click the Application value and enter the path to the vmware.exe file on your host system (put the pathname in double quotation marks), followed by -x, followed by the path to the VM's .vmx file (put the pathname in double quotation marks). For my configuration, I used the string value "C:\program files\vmware\vmware workstation\vmware.exe" -x "e:\vms\w2k1\w2k1.vmx". Close the registry editor.

Open the Windows Services snap-in. Locate and right-click the newly created VM service and select Properties. In the service's Properties dialog box, click the Log On tab. Ensure that Local System account is selected, and select the Allow service to interact with desktop check box, which Figure 1 shows. Click OK to close the service Properties dialog box. You can now use the Windows Services snap-in to start your VM service. By default, the service is configured as automatic, so the VM will start when your system starts. Each VM that you configure to run as a service will appear in its own window on the desktop. Because the VM is running as a service, you'll now be able to log off of your system, and the VM will continue to run.

Tuning VMware
The configuration steps you've performed thus far will let any number of VMs run as services without problems. However, you might find that some built-in VMware features will get in the way. For example, when multiple VMs attempt to start and share the same floppy drive, VMware displays a message that the floppy drive will start as disconnected on all VMs except for the one that was powered on first. You must click OK to acknowledge the message before the VM boot processes will continue. To prevent the need for manual intervention at boot time, you might want to configure the settings of each VM on the host so that their floppy drives don't connect at power on.

To configure a VM's floppy drive to start as disconnected, open the VM in VMware, double-click the floppy drive icon, then clear the Connect at Power On check box and click OK in the floppy drive's Settings dialog box. One other method for preventing the floppy drive from connecting at power on is to open the VM's .vmx configuration file in Notepad and set the floppy0.startConnected parameter to "false".

VMware hints might also interrupt a VM's startup process. You can prevent all hints from appearing for any particular VM by opening and editing the VM's .vmx file in Notepad. To disable all hints, add the line

hints.hideAll = "true"

to the file, as Figure 2 shows.

Take It to the Max
Now your VMs can run in ways you've never imagined. For example, you can configure a VM to run as a DC that your host OS can log on to. When you've attained the "unattainable dream" of running VMware as a service, the possibilities are endless.

Resources
WEB SITES
VMware
http://vmware.com

Windows Server 2003 Resource Kit Tools
http://www.microsoft.com/downloads



End of Article



Reader Comments
Finally! Chris, you can not believe how long i have been looking (hopeing) on how to run my VM's as service and do exactly what you say => running a DC in VM and have the host logon to it.

Great article, thanks!

Tom

Ps. A while back i had a hard time finding how to turn of the PC beep sound for a VMware session. I'd just like to pass on to everyone there is a 'mks.nobeep = "TRUE"' feature you can add to your vm's .vmx file.

Tom Decaluwe June 01, 2004


This is a great trick. We use a similiar method and install the AutoExNT service, another resource kit utility which allows you to run an autoexec.bat file as the local system account without logging in under a user session. You can then use the same command-lines Chris uses to run your VMWare machines without having to install them as services.

Sean Powell June 30, 2004


Anyone has a good tip to handle the shutdown of the services so that the VM session shuts down properly. I considered a shutdown script but I have yet to try one.

Rob Norman July 06, 2004


If you have more than one virtual machine, you can add them all into the command line in the registry. If one machine depends on another (such as an Exchange server depending on a DC), you could create two services with one dependant on another and maybe a timer to slow the second from starting until the first was totally up.

dulaw July 14, 2004 (Article Rating: )


What exactly is the -x for that is listed in the command "c:\program files\vmware\vmware workstation\vmware.exe" -x "e:\ms\w2k1w2k1.vmx"

vortex0007 July 14, 2004 (Article Rating: )


For those of you using Microsoft Virtual PC instead of VMWare, you can also do this by changing the Application Line to read "C:\Program Files\Microsoft Virtual PC\virtual pc.exe -singlepc -pc DC2K3 -launch" WITHOUT the quotes. where DC2K3 is the name of the virtual PC.

vortex0007 July 14, 2004 (Article Rating: )


I am new to this and using MS Virtual PC.
Nothing I try seems to work. Also ... what should be in the "ServiceName"\ImagePath\ string ? is this the same as the Parameters\Application\string ? Thanks

bill_domenz September 21, 2004 (Article Rating: )


I could not get MS Virtual PC to work with the -singlepc -pc TerminalServerVM -launch
but it does work with the -startvm switch. I suppose because this will install the vmc into the system account.

"C:\Program Files\Microsoft Virtual PC\virtual pc.exe" -startvm "q:\vm\TerminalServerVM.vmc"

RobertJTownley January 24, 2005 (Article Rating: )


You must log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
Friday at PASS Europe 2006

Kevin talks about the closing day of the event and shares a funny Microsoft film. ...

More fun TechEd 2005 Resources

Kevin points out some more TechEd resources ...

What service packs and fixes are available?

...


Windows OSs Whitepapers Why SaaS is the Right Solution for Log Management

Are You Satisfied?

A Preliminary Look at Deployment Plans for Microsoft Windows Vista

Related Events Check out our list of Free Email Newsletters!

Windows OSs eBooks Understanding and Leveraging Code Signing Technologies

A Guide to Windows Certification and Public Keys

SQL Server Administration for Oracle DBAs

Related Windows OSs Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.

Job Openings in IT


ADS BY GOOGLE SPONSORED LINKS FEATURED LINKS

Microsoft Exchange & Windows Connections event returns to Las Vegas Nov 10 - 13
Connections returns to Las Vegas for this exciting event where each attendee will receive SQL Server 2008 standard with 1 CAL. Co-located with Microsoft ASP.NET, SQL Server, and SharePoint Connections with over 250 in-depth sessions.

Free Online Event! Virtualization:Get the Facts!
Register now and attend this free, live in-depth online conference on November 13 and 20, 2008, produced by Windows IT Pro. All registrants are eligible to receive a complimentary one-year digital subscription to Windows IT Pro (a $49.95 value)!

Check Out Hyper-V Video on ITTV
Watch Karen Forster's interview on Hyper-V's performance on ITTV.net.

Ease Your Scripting Pains with the Flexibility of PowerShell!
Join MVP Paul Robichaux on December 11, 2008 at 11:00 AM EDT as he equips you with PowerShell basics in 3 introductory lessons, each followed by a live Q&A session—all on your own computer!

PASS Community Summit 2008 in Seattle on Nov 18-21
The don’t-miss event for Microsoft SQL Server Professionals. Register now and you’ll enjoy top-notch Microsoft and Community speakers and more.



Solving PST Management Problems
In this white paper, read about the top PST issues and how to administer local/network PST Files.

Get Protected -- Data Protection Manager 2007
Protect your virtualized environment with Data Protection Manager

Order Your SQL Fundamentals CD Today!
Learn how to use SQL Server, understand Office integration techniques and dive into the essentials of SQL Express and Visual Basic with this free SQL Fundamentals CD.

Maximize Your SharePoint Investment: Get Your Data Moving
Watch this web seminar now to learn how to maximize your SharePoint investment! Join us as we take a look at the complex business of securing, accessing and managing vast amounts of information in a global network and various ways to get your data moving.
Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing