faqts : Computers : Operating Systems : Emulators : VMWare

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

43 of 49 people (88%) answered Yes
Recently 9 of 10 people (90%) answered Yes

Entry

VMWare:What are command line parameters for VMWare v4 Windows?[Delphi/batch/automate/start/script]

Aug 13th, 2003 07:38
Knud van Eeden,


----------------------------------------------------------------------
--- Knud van Eeden - 12 August 2003 - 08:44 pm -----------------------


This might come handy if you want to start your VMWare with a different
operating system (e.g. from the command line, or from your program
written in Delphi, C++Builder, Visual C++, ..., a batch file), in order
to automate.

---

That is, you can start that particular operating system (say
Linux Red Hat v9) with just one click of a button from Delphi,
Visual C++, Borland C++ Builder, ..., combine it with other commands
which start automatically together, or running a
particular batch file from the command line.

---

To even further automate, you can run inside your operating system
some batch files when starting with 'power on', 'resume', or when
you stop your operating system with 'power off', 'suspend'.

So for example:

-you could start Linux Red Hat from the command line, and then
automatically let it run Nautilus with the current content of your
CD-ROM.

-you could start another Microsoft Windows XP from the command line,
and then automatically let it run Explorer with the current content of
some of your folders.

-you could start another Microsoft Windows XP from the command line,
and then automatically let it run Microsoft Excel with
your latest spreadsheet loaded.

---

If you on the MSDOS command line type:

 "C:\Program Files\VMware\VMware Workstation\vmware.exe" -help

you will see the possible command line parameters:

---

+-------------------------------------------------------------+
| Usage:                                                      |
|                                                             |
| ---                                                         |
|                                                             |
|  vmware.exe [<flags>] [configfile]*                         |
|                                                             |
| ---                                                         |
|                                                             |
| where <flags> are:                                          |
|                                                             |
| -v print program version                                    |
|                                                             |
| -x power on when a virtual machine is opened                |
|                                                             |
| -X as -x, also go to full screen mode                       |
|                                                             |
| -q close virtual machine at power off                       |
|                                                             |
| -s NAME=VALUE set variable NAME to VALUE                    |
|                                                             |
| -p parentDisk childDisk (points disk to correct parent disk)|
|                                                             |
+-------------------------------------------------------------+

---

Now the config file is the file with the extension .vmx in the 
directory

 c:\documents and settings\<username>\my documents\my virtual machines\

So if you are e.g. logged in with the current username 'administrator',
your config file will be stored in:

 c:\documents and settings\administrator\my documents\my virtual 
machines\

---

In order to automate, e.g. using a batch file or clicking once on a
button in Delphi (which might contain some further commands, like 'if
it is this task, start operating system1, else if it is another task.
start operating system2, and so on...) to start a specific VMWare
operating system:

---

To start VMWare with a particular operating system, you should give the
full path to the .vmx file for that operating system (the filepath will
depend on the conditions on your computer, so adapt this path):

---

The general format is:

<name of your VMWare executable> <full path to the .vmx of the 
operating system you want to
start> [-x | -X]

---

e.g. to start VMWare with Linux Red Hat v9.0, type on the MSDOS command
line:

"C:\Program Files\VMware\VMware Workstation\vmware.exe" "c:\Documents 
and Settings\Administrator\My Documents\My Virtual Machines\Linux Red 
Hat v9.0\Linux Red Hat v9.0.vmx"

---

e.g. to start VMWare with Linux Mandrake v9.0, type on the MSDOS 
command
line:

"C:\Program Files\VMware\VMware Workstation\vmware.exe" "c:\Documents 
and Settings\Administrator\My Documents\My Virtual Machines\Linux 
Mandrake v9.0\Linux Mandrake v9.0.vmx"

---

If you want this operating systems also to start running, use the
following command line parameters -x (for non full screen), or -X (for
full screen):

---

e.g. to start VMWare with Linux Red Hat v9.0, type on the MSDOS command
line, and start it, non-full screen:

"C:\Program Files\VMware\VMware Workstation\vmware.exe" -
x "c:\Documents and Settings\Administrator\My Documents\My Virtual 
Machines\Linux Red Hat v9.0\Linux Red Hat v9.0.vmx"

---

e.g. to start VMWare with Linux Mandrake v9.0, type on the MSDOS 
command
line, and start it, full screen:

"C:\Program Files\VMware\VMware Workstation\vmware.exe" -
X "c:\Documents and Settings\Administrator\My Documents\My Virtual 
Machines\Linux Mandrake v9.0\Linux Mandrake v9.0.vmx"

---

e.g. to start VMWare with Windows XP Professional, type on the MSDOS 
command
line, and start it, not full screen:
"C:\Program Files\VMware\VMware Workstation\vmware.exe" -
x "C:\Documents and Settings\Administrator\My Documents\My Virtual 
Machines\Windows XP Professional\Windows XP Professional.vmx"

---

If you want to further automate tasks *inside* the operating system
while starting up, you can put arbitrary commands in the following
4 default batch files

 poweroff-vm-default.bat

 poweron-vm-default.bat

 resume-vm-default.bat

 suspend-vm-default.bat

present in the guest operating systems, which are executed (as their
filename implies) during respectively:

 power off

 power on

 resume

 suspend

You can find these batch files in the directory:

+--------------------------------------------------------------+
| Directory of C:\Program Files\VMware                         |
|                                                              |
|08/09/2003  08:08 PM    <DIR>          .                      |
|08/09/2003  08:08 PM    <DIR>          ..                     |
|08/09/2003  08:08 PM    <DIR>          drivers                |
|04/03/2003  06:19 PM            49,246 hook.dll               |
|04/03/2003  06:19 PM               284 poweroff-vm-default.bat|
|04/03/2003  06:19 PM               284 poweron-vm-default.bat |
|08/09/2003  08:08 PM               337 resume-vm-default.bat  |
|08/09/2003  08:08 PM               338 suspend-vm-default.bat |
|08/13/2003  02:18 PM               296 tools.conf             |
|04/03/2003  06:19 PM            49,244 toolsuninst.dll        |
|04/03/2003  06:19 PM            57,461 uninstutil.dll         |
|04/03/2003  06:19 PM           262,253 VMControlPanel.cpl     |
|04/03/2003  06:19 PM            69,721 VMip.exe               |
|08/09/2003  08:09 PM            54,455 VMTUninst.isu          |
|04/03/2003  06:19 PM           168,043 VMwareService.exe      |
|04/03/2003  06:19 PM            90,213 VMwareTray.exe         |
|04/03/2003  06:19 PM           151,653 VMwareUser.exe         |
|              14 File(s)        953,828 bytes                 |
|               3 Dir(s)   3,047,088,128 bytes free            |
+--------------------------------------------------------------+

So if you edit this files in the guest operating system, and add the
one or more commands in there, you can automatically let this commands
execute or some programs run during say the start of that particular
operating system.

---

So for example to let your operating system, say Microsoft Windows XP
start while showing 'Explorer', edit the resume batch file
(in your guest operating system):

On the MSDOS command line type (but use any editor of your liking):

 edit c:\program files\vmware\resume-vm-default.bat

This will show the following:

+-------------------------------------------+
|@REM                                       |
|@REM   DO NOT modify this file directly as |
|@REM   it will be                          |
|@REM   overwritten the next                |
|@REM   time the VMware Tools are installed.|
|@REM                                       |
|@REM                                       |
|                                           |
|"C:\Program Files\VMware\VMip.exe" -renew  |
+-------------------------------------------+

---

Now edit this file and add your own commands (e.g. executable filenames
like the ones for Microsoft Excel, or a database like Microsoft Access,
or a compiler like Delphi, or C++ Builder, ..., which might have
other parameters like filenames to load)

---

IMPORTANT: If you add this commands, you must put them *ABOVE* the line

 "C:\Program Files\VMware\VMip.exe" -renew

or else you will get error messages.

---

So adding e.g. the line 'Explorer' *BEFORE* you get:

+-------------------------------------------+
|@REM                                       |
|@REM   DO NOT modify this file directly as |
|@REM   it will be                          |
|@REM   overwritten the next                |
|@REM   time the VMware Tools are installed.|
|@REM                                       |
|@REM                                       |
|                                           |
| Explorer                                  |
|                                           |
|                                           |
|"C:\Program Files\VMware\VMip.exe" -renew  |
+-------------------------------------------+

---

Save this result.

---

Possibly repeat the same action for the file:

 c:\program files\vmware\poweron-vm-default.bat

so to be sure you cover all possible startup situations (that is
startup is always or a 'resume', or a 'power on').

---

Next time when you power on or resume the machine via the command line
(you must use the -x or -X option to force a start of that operating
system, otherwise it will just open and do nothing more), that
command(s) will be run.

---

Further, to let your script or this script run upon starting that
operating system, you have to once set some settings in the
VMWare menu, for this operating system:

---

Steps: Overview:

 1. -Open your VMWare

 2. -Select the operating system you want to reboot
     from the list

     (e.g. Microsoft Windows XP Professional)

 3. -select from menu option 'Edit'

 4. -select from list 'Virtual Machine settings...'

 5. -select tab 'Options'

 6. -click once on line 'Power' to highlight it

 7. -in 'Run VMWare Tool Scripts' enable the checkboxes for when the
     script should run.

     If you want to run the script at startup,
     you can e.g. enable both the
     'After powering on'
     'After resuming'

 8. -click button 'OK'

 9. -this will have added to the .vmx file for
     this operating system the zero or more
     lines similar to the lines below:

         toolScripts.afterPowerOn = "TRUE"
         toolScripts.afterResume = "TRUE"


     Other possibilites are:

         toolScripts.beforeSuspend = "TRUE"
         toolScripts.beforePowerOff = "TRUE"

10. -You will have to start the operating system with the
     '-x' or '-X' command line option, so forcing it to
     start the operating system.

---

see also:

http://www.vmware.com/support/ws4/doc/new_guest_toolsconfig_ws.html

http://www.vmware.com/support/esx2/doc/esx20admin_scripts_vms.html

---
---

To even further automate:

Now what if you want to start more than one operating system
simultaneously from the command line?

You can put the name of the configuration file of each operating system
you want to start after the VMWare executable filename.

---

The general format is:

<name of your VMWare executable> <full path to the first .vmx of the 
operating system you want to
start> <full path to the second .vmx of the operating system you want 
to start>
<full path to the third .vmx of the operating system you want to 
start> ...
<full path to the last .vmx of the operating system you want to start>
[-x | -X]

---

You will find out that you soon reach the limit of the maximum length
of about 250 characters, if you use long filenames, when putting all
this on one line, after each other (you could e.g. opt to create
shorter filenames, but you will then also have to change some
information in VMWare).

---

So you better put this in a batch file, like the following below:

---

Save this text e.g. in a file with the extension .bat
(for example 'mybatchfile.bat')
and run it from the command line, or by double clicking on this
filename:

--- cut here ---------------------------------------------------------

@REM change to the c: drive, where usually your VMWare is installed
c:

@REM change to the VMWare directory, otherwise you get too long 
filenames, when concatenated on one line:
cd "c:\Documents and Settings\Administrator\My Documents\My Virtual 
Machines

@REM this example starts in VMWare simultaneously Linux Mandrake, 
Windows XP, and Linux Red Hat from the command line
"C:\Program Files\VMware\VMware Workstation\vmware.exe" -x "Linux 
Mandrake v9.0\Linux Mandrake v9.0.vmx" "Windows XP 
Professional\Windows XP Professional.vmx" "Linux Red Hat v9.0\Linux 
Red Hat v9.0.vmx"

--- cut here ---------------------------------------------------------

---

Note:

This has been tested from Microsoft Windows XP Professional, running
VMWare v4.0.0 for Windows workstation, and worked OK.

---
---

see also:

http://www.vmware.com/support/gsx/doc/guestd_gsx_linux.html

http://www.faqts.com/knowledge_base/view.phtml/aid/22119/fid/1149

----------------------------------------------------------------------