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.

Important

You cannot run scripts on 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.

1

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

@%SYSTEMROOT%\system32\ipconfig /release

resume

@%SYSTEMROOT%\system32\ipconfig /renew
2

Open a command prompt in the guest operating system.

3

Change directories to the VMware Tools installation directory.

The default installation directory is C:\Program Files\VMware\VMware Tools.

4

Type the command to enable the script.

VMwareToolboxCmd.exe script script-name enable
5

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.

6

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.