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.
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.
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.
Required IP Address Line
- 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.