[Version 5.0.2 and later]WASService command

The WASService command line tool lets you add any WebSphere Application Server process as a Windows service.

WebSphere Application Server processes that you could add as Windows services include:

If the installation wizard creates a Windows service during installation, the uninstaller program removes the Windows service. If you use the WASService command to create a service yourself, it is your responsibility to remove the service when it is no longer valid. The uninstaller program does not remove Windows services that you create with the WASService command.

User ID prerequisites

You must run the WASService.exe command from a user ID that belongs to the administrator group. The user ID must also have the following advanced user rights:

Location of command file

The WASService.exe command file is located in the install_root\bin directory.

WASService.exe command syntax for starting an existing service

The command syntax is as follows:

WASService.exe [-start] "service_name" [optional startServer.bat parameters]  

WASService.exe command syntax for creating a service

The command syntax is as follows:

WASService.exe -add service_name
    -serverName Server
   [-wasHome  install_root]
   [-configRoot configuration_repository_directory]
   [-startArgs additional_start_arguments]
   [-stopArgs additional_stop_arguments]
   [-userid execution id -password password]
   [-logFile service_log_file]
   [-logRoot server_log_directory]
   [-userScript path\setupCmdLine.bat]
   [-restart true | -restart false]

WASService.exe command syntax for deleting a service

The command syntax is as follows:

WASService.exe -remove service_name

WASService.exe command syntax for stopping a running service

The command syntax is as follows:

WASService.exe -stop "service_name" [optional stopServer.bat parameters]

WASService.exe command syntax for retrieving service status

The command syntax is as follows:

WASService.exe -status service_name

WASService.exe commands for stopping a server after enabling security

The default installation of a WebSphere server as a service does not provide the stopArguments values required to stop the service when global security is enabled. This is expected, since global security has not yet been configured and the values needed are not known at installation.

The parameters needed for the service are the same as required for using the stopServer command from the DOS command line: -username user_ID -password pw_value

Add the -stopArgs parameter values to the service by adding the service and using the same name for the service. The default name of the service shown in Windows Services utility is "IBM WebSphere Application Server V5 - server1".

The utility automatically adds the "IBM WebSphere Application Server V5 -" portion of the name and appends the value for the -stopArgs parameter that you supply in the WASService.exe command.

Use the following command to append the stopArgs parameter to the existing "IBM WebSphere Application Server V5 - server1" service:

WASService -add server1 
           -serverName server1  
           -stopArgs "-username user1 -password pass1"  

The command corresponds to the following stopServer command:

stopserver server1 -username user1 -password pass1

Before running the WASService command, verify that the server is not running by using the serverstatus -username user_ID -password pw_value command . The status indicated in the Windows Services might be inaccurate. After a status change, it can take several minutes or restarting the Windows Services to indicate the accurate status.

When you update an existing service, the WASService command returns several lines in the DOS window that end with:

"Service already exists, updating parameters..."

The WASService command and Windows Services respect capitalization of the service name, but might not flag such errors. An indication of an error is that you cannot stop the server from the Windows Services panel. If you misspell a parameter or a value, or if you use an incorrect parameter, such as stopArguments instead of stopArgs, you might see the following error when attempting to stop the service:

Could not stop the IBM WebSphere Application Server V5 - server1 service on Local Computer

The message is displayed if the server name is correct, but there is an error in the parameter or its value.The message indicates that Windows did not receive a response when expected from the service. Use the serverstatus utility from a DOS command line to verify the status of the server.

An alternative to modifying the existing service is to add a new service with a different name, such as, server1a For example:

WASService -add server1a 
           -serverName server1  
           -stopArgs "-username user1 -password pass1"

you add a new service, disable the original service and use only the new service to control server1.

A similar set of steps can be used to add stop arguments for any WebSphere Application Server service.

Parameters

Supported arguments include:

-add service_name
Creates a service named service_name.
-configRoot configuration_repository_directory
Optional parameter that identifies the configuration directory of the installation root directory of a WebSphere Application Server product.
-logFile service_log_file
Optional parameter that identifies a log file that the WASService command uses to record its activity.
-logRoot server_log_directory
Required parameter that identifies a wsinstance server log directory that the WASService command uses to determine if the server is running.
-remove service_name
Deletes the specified service.
-restart true | false
Restarts the existing service automatically if tyhe service fails when set to true.
-serverName Server_name
Identifies the server that the service controls.
-start service_name
Starts the existing service. The -start parameter is the default parameter; you can omit the -start parameter and still start the service.
-startArgs additional_start_arguments
Optional parameter that identifies additional parameters.
-status service_name
Returns the current status of the service, which includes whether the service is running or stopped.
-stop service_name
Stops the specified service.
-stopArgs additional_stop_arguments
Optional parameter that identifies additional parameters.
-userid execution_ID -password password
Optional parameters that identify a privileged user ID and password.
-userScript path\setupCmdLine.bat
Optional parameter that identifies the setupCmdLine.bat command file that the WASService command uses to understand wsinstance nodes.
-wasHome install_root
Optional parameter that identifies the installation root directory of the WebSphere Application Server product.

Creating a deployment manager service

This example creates a service called IBMWAS5Service - dmgr that starts the dmgr process:

WASService -add dmgr
  -servername dmgr
  -wasHome 
     "D:\Program Files\WebSphere\DeploymentManager"
  -logfile 
    "D:\Program Files\WebSphere\DeploymentManager\logs\dmgr\WS_startServer.log"
  -logRoot 
    "D:\Program Files\WebSphere\DeploymentManager\logs\dmgr"
  -restart true

Creating a node agent service

This example creates a service called IBMWAS5Service - nodeagent that starts the nodeagent process:

WASService -add nodeagent 
  -servername nodeagent 
  -wasHome 
     "D:\Program Files\WebSphere\AppServer"
  -logfile 
     "D:\Program Files\WebSphere\AppServer\logs\nodeagent\WS_startServer.log"
  -logRoot 
     "D:\Program Files\WebSphere\AppServer\logs\nodeagent"
  -restart true

Creating an Application Server service

This example creates a service called IBMWAS5Service - server2 that starts an Application Server process:

WASService -add server2
  -servername server2
  -wasHome 
     "D:\Program Files\WebSphere\AppServer"
  -logfile 
     "D:\Program Files\WebSphere\AppServer\logs\server2\WS_startServer.log"
  -logRoot 
     "D:\Program Files\WebSphere\AppServer\logs\server2"
  -restart true

Example of successful result

C:\install_root\bin> WASService -add testserver1 -serverName server1


Adding Service: testserver1
Config Root: C:\WebSphere\AppServer\config
Server Name: server1
Was Home: C:\WebSphere\AppServer\
Start Args:
Restart: 1
IBM WebSphere Application Server V5 - testserver1 service successfully added.

Example result when the user ID does not have the proper authorization

WASService -add "NodeAgent" -serverName nodeAgent -username websphereadm -password pass1


Adding Service: NodeAgent
Config Root: C:\WebSphere\AppServer\config
Server Name: nodeAgent
Was Home: C:\WebSphere\AppServer\
Start Args: -username websphereadm -password pass1
Restart: 1
Failed to add service: 1057

To correct this problem, grant the user ID the proper authorization and advanced user rights.


Related tasks
Automatically restarting WebSphere processes



Searchable topic ID:   rins_wasservice
Last updated: Jun 21, 2007 8:07:48 PM CDT    WebSphere Business Integration Server Foundation, Version 5.0.2
http://publib.boulder.ibm.com/infocenter/wasinfo/index.jsp?topic=/com.ibm.wasee.doc/info/ee/ae/rins_wasservice.html

Library | Support | Terms of Use | Feedback