Previous Page | Next Page

Using Windows System Tools with SAS under Windows

Starting SAS as a Windows Service


Overview of Starting SAS as a Windows Service

Starting SAS as a Windows service enables you to start SAS automatically or manually, define recovery procedures if SAS fails, and enable users to log on and log off a PC without interrupting SAS. When SAS is defined to start manually, you can start SAS either from an application by using the net start command or by using the Windows Services dialog box.

The general process for configuring SAS as a Windows service is as follows:

  1. Create an initialization (.INI) file.

  2. Install the .INI file to register SAS as a Windows service.

  3. If SAS is configured to start automatically, restart your machine. If SAS is configured to start manually, you can start SAS either from an application or the Services window in all Windows operating environments. For more information, see Starting a SAS Service.

If you have multiple SAS configurations, you can create an initialization file for each configuration.

SAS provides the SAS Service Configuration Utility (SAS SCU) to configure the service and install the .INI file.


Starting the SAS Service Configuration Utility

To start the SAS SCU, do one of the following:


Creating an Initialization File


Overview of the Initialization File

Before you can start SAS as a Windows Service, you need to configure and install an initialization (.INI) file. The. INI file is a Unicode file that

You create the initialization file either by using the SAS SCU graphical user interface (GUI) or by using a Unicode-capable text editor, such as Notepad. If you use the SAS SCU GUI, you specify only the required values and the SAS SCU creates the .INI file for you. If you use a text editor to create the .INI file, you must specify the SAS service settings and their values. You must save the file as a Unicode file, not as an ANSI or ASCII-encoded file. SAS Service INI File Settings and Default Values explains the settings that you specify to create a SAS service .INI file with a text editor.


Creating an Initialization File Using the SAS Service Configuration Utility

Use the SAS Service Configuration Utility (SAS SCU) that is shown in the following display to create the .INI file. After configuring the settings, click the Install/Save File tab to save and install the .INI file.

SAS Service Configuration Utility

[The SAS Service Configuration Utility dialog box]

To configure the INI file, select the following tab and modify the appropriate settings:

Install tab
Service Name

is the service name that is registered to Windows when the service is installed. The service name is also the name that is used when a net start or a net stop command is issued. This field is required. The default is SASService.

Display Name

is the name of the service that is displayed to user-interface applications. This field is required. The default is A SAS Service.

Start Type

specifies whether the SAS service is started manually, automatically, or is disabled. This field is required. The default is Manual. Manual specifies that the service can be started by another process. Automatic specifies that the service is started automatically during system startup. Disabled specifies that the service cannot be started.

Service Path

contains both the directory path in which SAS is installed and also the SAS command that is used to start the service. This field is required. For a new installation, the default path is the SAS installation path, followed by the command sas.exe -noterminal. If the SAS SCU has been installed previously, the default path is c:\Program Files\SAS\SASFoundation\9.2\ followed by sas.exe -noterminal. The NOTERMINAL system option is required. To start a SAS program as a service, add the SYSIN system option followed by the program pathname and filename to the Service Path. To select a service path, click ... (ellipse button).

Working Path

is the working path that is used by applications that use the SAS Service to create directories, store files, and log information. This field is optional. The default is the user's profile directory. Under Windows Vista and Windows 7, the user's profile is located at c:\Users\user ID\Documents\My SAS Files\9.2 Under all other Windows operating environments, the user profile is located at c:\Documents and Settings\user ID\My Documents\My SAS Files\9.2. To select a working path, click ... (ellipse button).

Dependencies

specifies one or more Windows services that must be started before this service is started. If a dependent service is installed and enabled, the service is started before this service is started. If a service is installed but disabled, this service will not be started.

To specify dependencies, type one or more service names separated by the pipe ( | ) character. For example, NetDDE|NetDDEdsdm.

Description

Type a description of the service. The description appears in the Windows Services window.

Remove tab

Remove Existing Service

specifies the name of the installed SAS service that you want to remove.

Options tab

Error Control

determines the error severity if the SAS Service fails to start. Select one of the following error controls:

Error Control Description
Ignore The error is logged. Startup operations continue.
Normal The error is logged and a message is displayed. Startup operations continue.
Severe The error is logged and startup operations continue by using the last successfully installed INI file.
Critical An attempt to log the error is made. If the startup operation is using the last known successful INI file, startup operations fail. If the startup operation is not using the last known successful INI file, it will attempt to restart the service by using the last successful INI file.

Access

is the level of access that an application has to the SAS Service. When you select an access level, such as Read, Write, or Execute, certain access type settings are set to 1(TRUE) in the INI file. To further configure all access types settings, select the appropriate boxes. For a description of access type settings, see SAS Service INI File Settings and Default Values. The access levels are

Read

enables an application to set the Interrogate, Query Configuration and Query Status access type settings. Selecting this access level sets the AccessInterrogate=, AccessQryCfg=, and AccessQryStatus= settings in the .INI file to 1(TRUE).

Write

enables an application to set the Change Configuration access type. Selecting this access level sets the AccessChgCfg= setting in the .INI file to 1(TRUE).

Execute

enables an application to set the Interrogate, Pause/Continue, Start Service, Stop Service, and Define Control access types. Selecting this access level sets the AccessInterrogate=, AccessPauseCont=, AccessStart=, AccessStop, and AccessUserDefCtrl= settings in the .INI file to 1(TRUE).

Account tab

System Account

specifies that the service is shared for all users that log on to this machine. To enable the service to interact with the user from the desktop, select Allow this Service to interact with the Desktop. When you select System Account, the ServiceStartName= setting in the INI file is set to LocalSystem.

This Account

specifies that the service is for a specific user only. When you select This Account, type the account name in the box. Then type the password in the Password and Confirm Password boxes.

Install/Save File tab

Install from file

Click the Install from file button to specify an initialization (INI) file to install.

Save settings to file

Click the Save settings to file button to save the settings that you have specified in the SAS Service Configuration Utility GUI to a file.

Show file contents

Select the Show file contents box if you want to display the initialization file that you want to install or save in the File Contents box.

About tab

displays the copyright information for the SAS Service Configuration Utility.


Creating the Initialization (INI) File Using a Unicode Text Editor

To create a SAS Service INI file by using any Unicode-capable text editor, such as Notepad, create a new file in the editor and assign a valid value to each of the settings in the following table. Type only one setting per line:

SAS Service INI File Settings and Default Values
Setting Name Required Explanation Valid Values Defaults Related SAS SCU Field
Service Name= Yes The SAS Service name registered to Windows. Can contain up to 32 characters (/ and \ are not valid). The name is not case sensitive and it must be contained in quotation marks. "SASService" Service Name
Display Name= Yes The name of the service that is displayed to user-interface applications. Can contain up to 256 characters, is not case sensitive, and must be contained in quotation marks. "A SAS Service" Display Name
Binary Pathname= Yes Contains the directory path in which the SAS Service INI file is installed, followed by the SAS command to start the service. The pathname must be contained in both brackets and quotation marks. ["SAS installation path\sas.exe -noterminal"] Service Path
Start Type= Yes Specifies whether the SAS Service is to start manually or automatically. SERVICE_AUTO_ START

SERVICE_ DEMAND_START

SERVICE_DISABLED

SERVICE_ DEMAND_ START Start Type
Dependencies= No Specifies Windows services that must be started before this service is started. One or more Windows service names, separated by the pipe (|) character. Enclose dependences in quotation marks. none Dependencies
Description No A description of the service The description can contain alphanumeric characters and must be enclosed in quotation marks. none Description
WorkDir= No The directory used by applications to store files created and used by the SAS Service. The path to the working directory must be contained in quotation marks. "Under Windows Vista and Windows 7- c:\Users\user ID" or Under Windows XP and 2003 - "c:\Documents and Settings\ user ID" Working Path
ErrorControl= Yes Determines the error severity if the SAS Service fails to start. SERVICE_ ERROR_ IGNORE

SERVICE_ ERROR_ NORMAL

SERVICE_ ERROR_ SEVERE

SERVICE_ ERROR_ CRITICAL

SERVICE_ ERROR_ NORMAL Error Control
Interactive= Yes Specifies whether the service allows a user to interact with the SAS desktop. 1(TRUE)

0(FALSE)

0(FALSE) Interactive Process
AccessChgCfg= Yes Modifies the SAS Service configuration. 1(TRUE)

0(FALSE)

1(TRUE) Change Configuration
Access Interrogate= Yes Requests that the SAS Service immediately update its current status. 1(TRUE)

0(FALSE)

1(TRUE) Interrogate
Access PauseCont= Yes Pauses and resumes the SAS Service. 1(TRUE)

0(FALSE)

1(TRUE) Pause/Continue
AccessQryCfg= Yes Makes queries about the SAS Service configuration. 1(TRUE)

0(FALSE)

1(TRUE) Query Configuration
AccessQry Status= Yes Queries Windows about the status of the SAS Service. 1(TRUE)

0(FALSE)

1(TRUE) Query Status
AccessStart= Yes Starts the SAS Service. 1(TRUE)

0(FALSE)

1(TRUE) Start Service
AccessStop Yes Stops the SAS Service. 1(TRUE)

0(FALSE)

1(TRUE) Stop Service
AccessUser DefCtrl= Yes Specifies a user-defined control code. 1(TRUE)

0(FALSE)

1(TRUE) Define Control
ServiceStart Name= No The Windows user account with proper user rights to run the SAS Service. LocalSystem or Windows account name LocalSystem This Account
Password= No The Windows account password. an encrypted password none Password

When you create an .INI file by using a text editor and you want to specify ServiceStartName for a specific user, the Windows account name must be of the format domainname\username and you must include an encrypted password in the PASSWORD setting name. You can use the PWENCODE procedure to create an encrypted password. For example, the following PWENCODE procedure specifies mypw as the input password:

   proc pwencode in='mypw';
   run;

The SAS log displays the encrypted password {sas001}bXlwdw==. You then specify {sas001}bXlwdw== as the value for the Password= setting in your .INI file. An encrypted password is necessary only if you specify Password= in an .INI file. In comparison, when you create an .INI file by using the SAS SCU, you specify a text password. The SAS SCU encrypts the password for you.

For more information about the PWENCODE procedure, see Base SAS Procedures Guide.


Installing a SAS Service

When you have created the initialization file, you use the initialization file to install SAS as a service. A SAS service can be installed either from the SAS SCU, from the command prompt, or from within an application.

To install a SAS Service by using the SAS SCU:

  1. Select the Install/Save File tab.

  2. Select Install from file.

  3. From the Open dialog box, select an INI file.

  4. Click Open.

To install a SAS Service from the command prompt, ensure that both the SAS Service Configuration Utility directory and the directory that contains the INI file are accessible from your system path. From the command prompt type sasservicemngr.exe path/filename.ini . When you install a SAS Service from the command prompt, user messages are disabled.

Note:   You can also install a service from the Install Tab for SAS SCU GUI.  [cautionend]

When a SAS Service is installed from an application, the command to install the service is sasservicemngr.exe path/filename.ini . The following table lists the return codes that can be passed back to the calling application:

Return Codes from Installing or Running a SAS Service
Numeric Code Error Code Description
0 SUCCESS The service has successfully been installed.
5 ERROR_ACCESS_DENIED Access to the Service Control Manager is denied.
6 ERROR_INVALID_HANDLE Error loading the Service Control Manager.
25 ERROR_NOT_FULL_PATH_CREATED The full path could not be created.
26 USER_CANCELED_INSTALL The user canceled the installation.
30 SUCCESS_NO_REG_DIR The service was installed but failed to register the working directory.
35 ERROR_BINPATH_NOTFOUND The service file was not found, no installation
40 ERROR_USER_CANCEL_NOSRVC The user canceled the installation because an INI file was not found.
50 ERROR_MISSING_FILE_ARGUMENT A required argument in the INI file is missing.
51 ERROR_INVLAID_FILE_ARGUMENT An INI file argument contains an incorrect value.
55 ERROR_OPENFILE The INI file could not be opened.
60 ERROR_ITEMTOOLARGE A string value exceeds the maximum character limit.
65 ERROR_PASSED_DECRYPT_FAILED The password could not be decrypted.
87 ERROR_INVALID_PARAMETER A service parameter is incorrect.
123 ERROR_INVALID_NAME The specified service name is not valid.
1057 ERROR_INVALID_SERVICE_ACCOUNT The account name is incorrect or does not exist.
1060 ERROR_SERVICE_DOES_NOT_EXIST The specified service does not exist as an installed service.
1065 ERROR_DATABASE_DOES_NOT_EXIST The specified database does not exist.
1072 ERROR_SERVICE_MARKED_FOR_DELETE The specified service has been marked for deletion.
1073 ERROR_SERVICE_EXISTS A duplicate service name exists on the network.
1078 ERROR_DUPLICATE_SERVICE_NAME A duplicate display name exists on the network.


Starting a SAS Service

A SAS Service can be started automatically or manually. If the SAS Service is configured to start automatically, the service starts when the system starts. If the SAS Service is configured to start manually, the service can be started either from an application by using the net start command or by using the Services dialog box.

To start a SAS Service using the Services dialog box:


Removing a SAS Service

A SAS Service can be removed as a Windows service from the SAS SCU or from the command prompt.

To remove a SAS Service by using the SAS SCU:

  1. Open the SAS SCU and click the Remove tab.

  2. Select the SAS Service from the Remove Existing Services box.

  3. Click Remove.

  4. Select Yes to confirm the removal of the service from the Remove Service dialog box.

To remove a SAS Service from the command prompt, type sasservicemngr.exe /remove <servicename> .

Previous Page | Next Page | Top of Page