On Windows guest operating systems, you can write scripts to automate guest operating system operations when you change the power state of a virtual machine.
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.
The VMware Tools service, or daemon (vmtoolsd), runs scripts. Because vmtoolsd runs as root on Linux, Mac, Solaris, and FreeBSD, and as System on Windows, the scripts 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.
- 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 Exit Codes for the VMware Tools Configuration Utility.
- Write a new script or modify default scripts and save them as .bat files with new names.
The default scripts for power-on and power-off operations are placeholders only. These scripts are located in the Program Files\VMware\VMware Tools directory.
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 Script Required IP Address Line suspend
- Open a command prompt in the guest operating system.
- Change directories to the VMware Tools installation directory.
The default installation directory is C:\Program Files\VMware\VMware Tools.
- Type the command to enable the script.
VMwareToolboxCmd.exe script script-name enable
- Type the command to use the custom script that you created.
VMwareToolboxCmd.exe script script-name set script-path
For script-path, use the full path to the file, such as, C:\Temp\poweron-my-vm.bat.
- Type the command to verify that the custom script that you specified is now being used.
VMwareToolboxCmd.exe script script-name current
The VMware Tools service runs the script whenever the specified power operation occurs.