Using Windows System Tools with SAS under Windows |
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:
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:
Select Start Programs your-SAS-System-folder SAS 9.2 License Renewal & Utilities SAS Service Configuration Utility
From the SAS SCU directory, type sasservicemngr.exe . The default SAS SCU directory is c:\Program Files\SAS\SASFoundation\ 9.2\core\sasscu.
Creating an Initialization File |
Creating an Initialization File Using the SAS Service Configuration Utility
Creating the Initialization (INI) File Using a Unicode Text Editor
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
specifies if the service is to start automatically or manually
specifies the level of access that an application has to the SAS service
names other Windows services that must be started before this service can be started
defines the actions that Windows is to complete if SAS fails to start as a service
specifies whether the SAS service is a system account or a local account
specifies whether the user can interact with the SAS desktop.
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.
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
To configure the INI file, select the following tab and modify the appropriate settings:
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.
is the name of the service that is displayed to user-interface applications. This field is required. The default is A SAS Service.
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.
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).
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).
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.
Type a description of the service. The description appears in the Windows Services window.
determines the error severity if the SAS Service fails to start. Select one of the following error controls:
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
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).
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).
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).
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.
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.
Click the Install from file button to specify an initialization (INI) file to install.
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.
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.
displays the copyright information for the SAS Service Configuration Utility.
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:
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 | 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 | Error Control |
Interactive= | Yes | Specifies whether the service allows a user to interact with the SAS desktop. | 1(TRUE) | 0(FALSE) | Interactive Process |
AccessChgCfg= | Yes | Modifies the SAS Service configuration. | 1(TRUE) | 1(TRUE) | Change Configuration |
Access Interrogate= | Yes | Requests that the SAS Service immediately update its current status. | 1(TRUE) | 1(TRUE) | Interrogate |
Access PauseCont= | Yes | Pauses and resumes the SAS Service. | 1(TRUE) | 1(TRUE) | Pause/Continue |
AccessQryCfg= | Yes | Makes queries about the SAS Service configuration. | 1(TRUE) | 1(TRUE) | Query Configuration |
AccessQry Status= | Yes | Queries Windows about the status of the SAS Service. | 1(TRUE) | 1(TRUE) | Query Status |
AccessStart= | Yes | Starts the SAS Service. | 1(TRUE) | 1(TRUE) | Start Service |
AccessStop | Yes | Stops the SAS Service. | 1(TRUE) | 1(TRUE) | Stop Service |
AccessUser DefCtrl= | Yes | Specifies a user-defined control code. | 1(TRUE) | 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:
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.
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:
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:
Under Windows Vista, select Start Settings Control Panel System and maintenance Administrative tools Services
Under Windows 7, select Start Settings Control Panel System and security Administrative tools Services
Under all other Windows operating environments, select Start Settings Control Panel Administrative Tools Services
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:
Select the SAS Service from the Remove Existing Services box.
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> .
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.