VMware Tools Help : VMware Tools Control Panel : Use Custom VMware Tools Scripts

Use Custom VMware Tools Scripts
You can use scripts to automate guest operating system operations when you change the power state of a virtual machine. You can also edit default scripts or associate custom scripts with power operations.
For example, when you power off a virtual machine, by default the poweroff-vm-default script runs if the virtual machine is set to shut down the guest operating system rather than abruptly power off.
Scripts are run by the VMware Tools service, or daemon (vmtoolsd). Because vmtoolsd is run as root on Linux, Solaris, and FreeBSD and 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.
Important
You cannot run scripts on Windows NT, Me, Windows 98, and Windows 95 guest operating systems.
 
Prerequisites
On Linux, Solaris, and FreeBSD guest operating systems, to edit a script, make sure xterm and vi are installed in the guest operating system and are in your PATH, or specify which editor to use by setting the EDITOR environment variable.
Procedure
1
Edit scripts in Program Files\VMware\VMware Tools.
Edit scripts in /etc/vmware-tools.
2
You can also use the Edit button on the Scripts tab.
If you edit a default script and do not change the name, the script is overwritten during the next VMware Tools update.
3
Click the Scripts tab in the VMware Tools control panel.
4
In the ScriptEvent list, select the power operation to associate with the script.
5
Select the Use Script check box, select Custom script, and click Browse to locate the script.
6
If you run a script and it executes successfully, the script might still fail later. Because the script is run as the logged-in user, the script might fail when run by the VMware Tools daemon during a power operation. This failure happens because the script might have a different working directory when it is run during a power operation, as a different logged-in user.
After you complete this procedure, the VMware Tools service runs the script whenever the specified power operation occurs.