C:\winnt\system32\sc.exe create service-name binPath= \"fully-qualied-path-to-appservService.exe
\"fully-qualied-path-to-asadmin.batstart-command\"
\"fully-qualied-path-to-asadmin.batstop-command\""
start= auto DisplayName= "display-name"
Note– There is no space between binpath andthe equals sign (=). There must be a space after
theequals sign and before the path.
Forexample, to create a service called SunJavaSystemAppServer DOMAIN1 that starts and stops
thedomain domain1, using a password le C:\Sun\AppServer\password.txt:
C:\windows\system32\sc.exe create domain1 binPath=
"C:\Sun\AppServer\lib\appservService.exe \"C:\Sun\AppServer\bin\asadmin.bat
start-domain --user admin --passwordfile C:\Sun\AppServer\password.txt domain1\"
\"C:\Sun\AppServer\bin\asadmin.bat stop-domain domain1\"" start= auto
DisplayName= "SunJavaSystemAppServer DOMAIN1"
Tocreate a service that starts and stops the node agent agent1:
C:\windows\system32\sc.exe create agent1 binPath=
"C:\Sun\AppServer\lib\appservAgentService.exe \"C:\Sun\AppServer\bin\asadmin.bat
start-node-agent --user admin --passwordfile C:\Sun\AppServer\password.txt agent1\"
\"C:\Sun\AppServer\bin\asadmin.bat stop-node-agent agent1\"" start= auto
DisplayName= "SunJavaSystemAppServer AGENT1"
Note– The start and stop commands entered as part of the binPath= parametermust have the
correctsyntax. To test, run the commands from the command prompt. If the commands do not
properlystart or stop the domain or node agent, the service does not work correctly.
Note– Don’t use a mixture of asadmin startand stop commandsand service start and stops.
Mixingthe two can cause the server status to be out of sync. For example, the service might not
showthat the component has started even though the component is not running. To avoid this
situation,always use the sc.exe commandto start and stop the component when using
services.
Ifyour sc.exe create command did not properly create the service, delete the service and try
again.To delete the service, use the sc.exe delete "service-name"command.
RestartingAutomatically on the MicrosoftWindows Platform
SunGlassFishEnterprise Ser ver2.1 Administration Guide December 2008224