Service utility (dbsvc) for Windows

Creates, modifies, and deletes SQL Anywhere services.

Syntax
dbsvc [ modifier-options ] -d svc
dbsvc [ modifier-options ] -g svc
dbsvc [ modifier-options ] -l
dbsvc [ modifier-options ] -u svc
dbsvc [ modifier-options ]  creation-options -w svc details
dbsvc [ modifier-options ] -x svc
details:
<full-executable-path> [ options ]
Major option Description
@data

Reads in options from the specified environment variable or configuration file. See Using configuration files.

If you want to protect passwords or other information in the configuration file, you can use the File Hiding utility to obfuscate the contents of the configuration file. See File Hiding utility (dbfhide).

-d service-name Removes the named service from the list of services. If you supply -y, the service is deleted without confirmation.
-g service-name Lists the definition of the service, not including the password.
-l Lists the available SQL Anywhere services.
-u service-name Starts the service named service-name.
-w executable parameters

Creates a new service, or overwrites one if one of the same name exists. If you supply -y, the existing service is overwritten without confirmation.

You must supply the full path to the executable that you want to use as a service, as the account under which the service is running may not have the appropriate SQL Anywhere installation directory in its path.

You must supply parameters appropriate for the service you are creating.

See:

-x service-name Stops the service named service-name.
Creation option Description
-a acct

Names the Windows account. All services run under a Windows account. If you run under an account you have created, you must name the account with the -a option and supply a password with the -p option.

The Login as a Service privilege is required for all accounts other than the LocalSystem account. If an account does not have the Login as a Service privilege enabled, you are prompted to enable it. If the -y option is also specified, dbsvc attempts to grant the Login as a Service privilege without prompting you. If the -q option is specified without the -y option, you are not prompted to grant the Login as a Service privilege and dbsvc fails.

-as All services run under a Windows account. When -as is specified, the service runs under the Windows LocalSystem account. No password is required. One of -a or -as must be used.
-i Displays an icon that you can double-click to display the database server messages window.
-p Use this option with the -a option to specify the password for the account under which the service runs.
-rg dependency,... Specifies one or more load ordering groups that must be started before the service being created is allowed to start.
-rs dependency,... Specifies that all the services in the list must have started before the service being created is allowed to start.
-s startup Sets startup behavior for SQL Anywhere services. You can set startup behavior to Automatic, Manual, or Disabled. The default is Manual.
-sd description Use this option to provide a description of the service. The description appears in the Windows Service Manager.
-sn name

Use this option to provide a name for the service. This name appears in the Windows Service Manager. If you do not specify the -sn option, the default service name is SQL Anywhere - svc. For example, the following service is named SQL Anywhere - myserv by default.

dbsvc -as -w myserv
"c:\Program Files\SQL Anywhere 11\bin32\dbeng11.exe"

To have the service name myserv appear in the Windows Service Manager, you need to execute the following (entered all on one line):

dbsvc -as -sn myserv -w myserv
"c:\Program Files\SQL Anywhere 11\bin32\dbeng11.exe"
-t type

Specifies the type for this service. You can choose from the following types:

The default setting for all service types is Standalone.

Modifier option Description
-cm

Displays the command used to create the service. This option can be used to output the creation command to a file, which can then be used to add the service on another computer or restore a service to its original state if changes have been made to it. You must specify the -g option or -l option with -cm or the command fails. Specifying -g displays the creation command for the specified service, while specifying -l displays the creation command for all services.

If the specified service does not exist, the command to delete the service is generated. For example, if service_1 does not exist on the computer, dbsvc -cm -g service_1 would return the following command to delete the service_1 service:

dbsvc -y -d "service_1"

If the service does not use the LocalSystem account, there is no way to retrieve the password, so it is not included in the command that is generated. If you created the service with -a user -p password, only -a user is included in the output.

-o log-file

Writes output from the Service utility (dbsvc) to the specified file. The -o option must occur before the -d, -g, -l, -u, and -x options. When you specify the -o option for both dbsvc and for the executable that you are running as a service (for example, the database server), log files are created for both. For example:

dbsvc -o out1.txt -y -as -w mydsn install-dir\bin32\dbsrv11 -n mysrv -o c:\out2.txt

In this case, the output from dbsvc is logged to out1.txt, while the output from the database server is logged to c:\out2.txt.

-q Do not display messages in the database server messages window. If you specify -q, it is also recommended that you specify a file where messages are logged using the -o option. If you specify this option when modifying or deleting an existing service, you must also specify -y or the operation will fail.
-y Automatically performs the action without prompting for confirmation. This option can be used with the -w or -d options. If you specify -q when modifying or deleting an existing service, you must also specify -y or the operation will fail.
Remarks

A service runs a database server or other application with a set of options. This utility provides a comprehensive way of managing SQL Anywhere services on Windows. You must be a member of the Administrators group on the local computer to use the Service utility.

You can access the Service utility in the following ways:

  • From Sybase Central, using the Create Service Wizard. See Creating Windows services.
  • At a command prompt, using the dbsvc command.

Exit codes are 0 (success) or non-zero (failure). See Software component exit codes.

See also
Example

Create a personal server service called myserv, which starts the specified server with the specified parameters. The server runs as the LocalSystem user:

dbsvc -as -w myserv "c:\Program Files\SQL Anywhere 11\bin32\dbeng11.exe" -n myeng -c 8m "c:\temp\mysample.db"

Create a network server service called mynetworkserv. The server runs under the local account, and starts automatically when the computer is restarted:

dbsvc -as -s auto -t network -w mynetworkserv "c:\Program Files\SQL Anywhere 11\bin32\dbsrv11.exe" 
-x tcpip -c 8m "c:\temp\mysample.db"

List all details about service myserv:

dbsvc -g myserv

Delete the service called myserv, without prompting for confirmation:

dbsvc -y -d myserv

Create a service dependent on the Workstation service and the TDI group:

dbsvc -rs Workstation -rg TDI -w ...

Create a service called mysyncservice:

dbsvc -as -s manual -t dbmlsync -w mysyncservice "c:\Program Files\SQL Anywhere 11\bin32\dbmlsync.exe" 
-c "SQL Anywhere 11 CustDB"

Generate the command to create the service_1 service and output it to a file called restoreservice.bat:

dbsvc -cm -g service_1 > restoreservice.bat

The restoreservice.bat file contains the following:

dbsvc -t Standalone -s Manual -as -y -w "service_1"
"c:\Program Files\SQL Anywhere 11\bin32\dbeng11.exe"

Create a MobiLink listener service that is started manually:

dbsvc -as -i -w myListener "c:\Program Files\SQL Anywhere 11\bin32\dblsn.exe" "@c:\temp\dblsn.opt"

Start the myListener service:

dbsvc -u myListener

Stop the myListener service:

dbsvc -x myListener

Create a Volume Shadow Copy Service (VSS) service that is started automatically when the database server starts:

dbsvc -as -s Automatic -t vss -w SAVSSWriter "c:\Program Files\SQL Anywhere 11\bin32\dbvss11.exe"