General

CodeSonar As A Windows Service (Windows Only)

By default, CodeSonar will run as a Windows Service on Windows machines. Running as a service provides several advantages, but is not required; users can specify that CodeSonar should be run without services.

Note in particular that Windows Services do not have access to mapped network drives. If you are analyzing files stored on mapped drives, you should run without services.



Running As A Windows Service

By default, CodeSonar will run as a Windows service on Windows machines. This provides several advantages for managing the CodeSonar hub and launch daemon:

Windows Build Wizard On screen 1, make sure that Use Services is selected (it will be selected by default).
Command Line Build No special actions are necessary.

Windows Authentication

The first time you run CodeSonar as a Windows service, you may need to provide authentication. If so, a dialog will be displayed during the build process.

screenshot: services authentication dialog

Windows Permissions

The Windows credentials that you use to authenticate a newly-created CodeSonar service must be for an account with Windows "Administrator" privileges for the current machine.

If you have authenticated a CodeSonar service with a Windows account that has insufficient privileges, you can change the service owner.

Running Without Windows Services

The CodeSonar hub and launch daemon can be run without services.

Hub Use the -no-services option to the codesonar hub-start command. For example:
codesonar hub-start -no-services myhubdir localhost:7340
If you are starting a hub with the CodeSonar configuration tool, the tool will ask you to specify whether or not you wish to run the hub as a service.
Launch Daemon,
explicitly started
Use the -no-services option to the codesonar install-launchd command. For example:
codesonar install-launchd -no-services localhost:7340
Launch Daemon,
implicitly started
by analysis
(The built project and analysis results are not affected by the absence of services, but the advantages described above will not apply.)
Windows Build Wizard On screen 1, make sure that Use Services is not selected.
Command Line Build Use the -no-services option to the codesonar analyze command. For example:
codesonar analyze MyProj -no-services localhost:7340 make

Alternatively, you can set USE_SERVICES=No in the project configuration file. Note that this parameter is ignored by the Windows build wizard and by the codesonar install-launchd command.

Uninstalling Services

To uninstall the CodeSonar services, use the following command line.

codesonar uninstall-services

If you have services for multiple installations of CodeSonar on a machine, you can uninstall all of them at once:

codesonar uninstall-services -all-installs

This functionality is also available through the CodeSonar configuration tool.

Service Management

Microsoft provides instructions to Start, stop, pause, resume, or restart a service.

Change the Hub Service Owner

There are a number of cases in which you might need to change the owner of the hub service. For example:

To change the service owner, do the following.

  1. Open the Windows Services dialog.
  2. Find the CodeSonar hub service in the list of services. It will have a name of the form "CodeSonar Hub (cshubnum)", where num is a number.
  3. Right-click on the CodeSonar hub service name and select Properties from the menu that pops up.
    The service properties dialog will open.
  4. Change to the Log On tab.
  5. Set the fields of the Log On tab to select the account that should be the owner of the hub service: either This account must have full control of the hub directory and all its contents.
  6. Click OK.

When the service next restarts, its owner will change to your new selection.