Compartilhar via


Configuring Virtual Server scripts

Configuring Virtual Server scripts

In the Virtual Server Attached Scripts pane, you can specify a script to run when a particular Virtual Server event occurs, or you can remove a script that was previously specified. For a script to run, you must enable scripting for Virtual Server. For instructions on adding and removing Virtual Server scripts and enabling scripting, see Configure Scripts.

Virtual Server executes command-line parameters or scripts that you specify for a Virtual Server event. To run a script, use the following syntax: script_program script_name. For example, you can run a script named myscript.vbs by using CScript, the command-line version of Windows Script Host, as follows:

cscript myscript.vbs

If Virtual Server cannot execute a command, this problem is recorded in the Virtual Server event log. However, if the command or script is executed but results in an error, the error cannot be recorded in the Virtual Server event log because Virtual Server only validates that the command line was executed.

Scripts that execute when Virtual Server starts or stops are executed in a new process in the logon session of the Virtual Server service, which runs under the Network Service account by default. As a result, any UI that the script may try to present will not be visible on the local computer. In general, you should not attempt to display UI from these scripts.

Also, keep in mind that the Network Service account might not have the user right required to perform one or more of the actions in the script. In such cases you need to either modify the script or grant the user rights to the Network Service account. When possible you should modify the script because granting additional user rights to an account makes it more vulnerable to attack. If you need to grant a user right, from a command prompt, type:CACLS "%DIR%" /C /E /G "NT AUTHORITY\NetworkService":permission

Other scripts are executed in a new process in the logon session of an individual virtual machine, which runs under the user account configured for that virtual machine. Because the user account might not have the permission required to display UI, you also should not try to display UI from these other scripts."

You can specify a script to run for the Virtual Server events listed in the following table.

Event Description

Virtual Server starts

Virtual Server is started.

Virtual Server stops

Virtual Server is stopped.

Any virtual machine is turned on

A virtual machine is turned on.

Any virtual machine is restored

A virtual machine is restored from a saved state.

Any virtual machine is turned off (saved)

State is saved for a virtual machine. (The virtual machine is automatically turned off when its state is saved.)

Any virtual machine is turned off (not saved)

A virtual machine is turned off without its state being saved.

Any virtual machine is turned off within the guest environment

A virtual machine is turned off because a user shut down the guest operating system. Note that, as with a physical computer, when the Microsoft Windows NT operating system is shut down, the virtual machine is not automatically turned off.

Any virtual machine is reset

A virtual machine is reset.

No heartbeat is detected for any virtual machine

A heartbeat for a virtual machine has not been received for three minutes, as follows: One heartbeat per minute is expected. When no heartbeat is detected for more than a minute, Virtual Server prompts the guest operating system for a heartbeat every 10 seconds for two minutes. If no heartbeat is detected at the end of two minutes, this event is generated.

Any virtual machine experiences a guest processor error

Virtual Server receives an error from a virtual processor.

Any virtual machine receives a warning due to low disk space on the physical computer

Virtual Server has received a warning about low physical disk space for the virtual hard disk attached to a virtual machine. A warning is generated when available disk space is 100 MB.

Any virtual machine receives an error due to low disk space on the physical computer

Virtual Server has received an error about low physical disk space for the virtual hard disk attached to a virtual machine. This error means that there is no longer any available disk space. The virtual machine pauses until more disk space is available. Virtual machine state is not saved when this condition is reached because there is not sufficient disk space to create the virtual machine saved-state (.vsv) file.

Note

In addition to the command-line executables that you can specify on this page, you can also use scripts to manage Virtual Server through its COM interface. For more information, see Virtual Server scripting support.