Do more with
InstallShield 2009 » InstallScript Language Reference
The ServiceAddService function adds the service specified by szServiceName to the list of services registered on the system. You can customize the SERVICE_IS_PARAMS structure to control additional service creation elements. ServiceAddService does not install any files; you must install the service file yourself during the installation. This function is supported only for Windows NT, Windows 2000, and Windows XP systems; the function will fail on Windows 95, Windows 98, and Windows Me systems.
If the service specified by szServiceName already exists, ServiceAddService reconfigures it to the parameters specified in the function call. If the existing service is running when ServiceAddService is called, the installation attempts to stop the service before attempting to reconfigure the service. If the service cannot be stopped, ServiceAddService reconfigures the service and sets BATCH_INSTALL to non-zero so that Windows can complete the service reconfiguration after reboot.
ServiceAddService ( szServiceName, szServiceDisplayName, szServiceDescription, szServicePathFile, bStartService, szStartServiceArgs );
Specifies the name of the service.
Specifies the display name of the service.
Specifies the service description. (The service description is relevant only on Windows 2000 and later.)
Specifies the path to the service executable file and, optionally, command line parameters that are passed to the service whenever it is started.
Specifies whether to start the service after adding it.
Specifies command line arguments that are passed to the service only when it is started by the installation.
ServiceAddService Return Values
Indicates that the function successfully added or reconfigured the service.
Indicates that the function was unable to add or reconfigure the service.
If this function fails, additional error information may be available by calling GetExtendedErrInfo and checking the value of its third argument. (This value typically indicates the result of internally calling the Windows API function GetLastError after a call to a Windows API function failed.)
You can obtain the error message text associated with a large negative return valuefor example, -2147024891 (0x80070005)by calling FormatMessage.
If logging is enabled when ServiceAddService is called, the service is logged for uninstallation whether or not the service existed already and is removed when the application is uninstalled. If you are adding a service that should not be uninstalled, disable logging before calling this function.
Note that the publicly defined structuresSERVICE_IS_PARAMS and SERVICE_IS_STATUSare not used when the service is uninstalled automatically. If you want to specify non-default settings when uninstalling the service, disable logging when adding the service and then remove the service manually during uninstallation by calling ServiceRemoveService directly from the script.
Open in new window
IT issues often require a personalized solution. With Ask the Experts™, submit your questions to our certified professionals and receive unlimited, customized solutions that work for you.
Start 7-Day Free Trial
Start 7-Day Free Trial