Custom VMware Tools Scripts for
Windows
For Windows guest operating systems,
you can write scripts to automate guest operating system operations when you change the
power state of a virtual machine.
- Familiarize yourself with the default VMware Tools scripts. See Default VMware Tools Scripts.
- If you plan to script commands and need to know what the exit codes are, see Common Exit Codes.
For Windows guest operating
systems, you can write new scripts or modify default scripts, save them with
new names, and configure VMware Tools to use your custom script instead of the
default script.
Scripts are run by the VMware
Tools service, or daemon (
vmtoolsd
). Because
vmtoolsd
is run as
System on Windows, the scripts are run in a separate session from the session
of the logged-in user. The VMware Tools daemon does not detect desktop
sessions, which means that it cannot display graphical applications. Do not
attempt to use custom scripts to display graphical applications.
You cannot run
scripts on NetWare, Windows NT, Me, Windows 98, and Windows 95 guest operating
systems.
- Write a new script or modify default scripts and save them as.batfiles with new names.The default scripts for power-on and power-off operations are placeholders only. These scripts are located in theProgram Files\VMware\VMware Toolsdirectory.The scripts for suspend and resume operations contain a line that releases or renews the IP address for the virtual machine. You must add this line first when you write custom scripts for these operations.Default ScriptRequired IP Address Linesuspend@%SYSTEMROOT%\system32\ipconfig /releaseresume@%SYSTEMROOT%\system32\ipconfig /renew
- Open a command prompt in the guest operating system.
- Change directories to the VMware Tools installation directory.The default installation directory isC:\Program Files\VMware\VMware Tools.
- Type the command to enable the script.VMwareToolboxCmd.exescriptscript-nameenable
- Type the command to use the custom script that you created.VMwareToolboxCmd.exescriptscript-namesetscript-pathForscript-path, use the full path to the file, such asC:\Temp\poweron-my-vm.bat.
- Type the command to verify that the custom script that you specified is now being used.VMwareToolboxCmd.exescriptscript-namecurrent
The VMware Tools service runs
the script whenever the specified power operation occurs.