WASService command

 

Overview

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.

The command syntax is as follows:

WASService.exe [-start] service_name 

 

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

 

WASService.exe command syntax for retrieving service status

The command syntax is as follows:

WASService.exe -status service_name

 

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

Optional 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.

-server 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.

 

Create 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\startServer.log"
           -logRoot "D:\Program Files\WebSphere\DeploymentManager\logs\dmgr"
           -restart true

Create 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\startServer.log"
           -logRoot "D:\Program Files\WebSphere\AppServer\logs\nodeagent"
           -restart true

Create 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\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 server processes