Restarting Automatically on the Microsoft Windows
Platform

To restart automatically on Microsoft Windows, create a Windows Service.
Use the appservService.exe and appserverAgentService.exe executables shipped with Sun GlassFish Enterprise Server in conjunction
with the Service Control command (sc.exe) provided by Microsoft.

The sc.exe command comes with Windows XP
and is either located in the C:\\windows\\system32 directory
or C:\\winnt\\system32 directory.

The start and stop commands entered as part of the binPath= parameter
must have the correct syntax. To test, run the commands from the command prompt.
If the commands do not properly start or stop the domain or node agent, the
service will not work correctly.

Also, do not use a mixture of asadmin start and stop commands and service
start and stops. Mixing the two can cause the
server status to be out of sync. For example, the service might not show that
the component has started even though the component is not running. To avoid
this situation, always use the sc.exe command to start
and stop the component when using services.

Security for Automatic Restarts

Handle the password and master password required when starting in one
of the following ways:

On Microsoft Windows, configure the service to ask the user
for the password.

In the Services Control Panel, double-click the service you
created.

In the Properties window, click the Log On tab.

Check “Allow service to interact with desktop”
to prompt for the required passwords when starting the component.

You
have to log in to see the prompts, and entries are not echoed back as you
type them. This method is the most secure way to use the services option,
but user interaction is required before the service becomes available.

If the “interact with desktop” option is not set, the service
stays in a “start-pending” state and appears to hang. Kill the
service process to recover from this state.

On Windows or UNIX, create a domain using the --savemasterpassword=true option and create a password file to store the admin password.
When starting the component, use the --passwordfile option
to point to the file that contains the password. The admin password can also
be added by using the --password option with the asadmin
start command. Be aware that this method is less secure because
the admin password is stored in clear text.

For example:

Create a domain with a saved master password. Using this syntax,
you are prompted for the admin password and master password: