Srvany.exe: Applications as Services Utility Topics | Previous | Next

Running an Application as a Service


To specify an application to run as a service, you must use a registry editor to add information to the Windows registry. You also have the option of setting any required startup parameters to run the application, as well as setting the working directory used by the application.

 

note-icon

Caution

Do not use a registry editor to edit the registry directly unless you have no alternative. The registry editors bypass the standard safeguards provided by administrative tools. These safeguards prevent you from entering conflicting settings or settings that are likely to degrade performance or damage your system. Editing the registry directly can have serious, unexpected consequences that can prevent the system from starting and require that you reinstall Windows 2000. To configure or customize Windows 2000, use the programs in Control Panel or Microsoft Management Console (MMC) whenever possible.

Starting a Registry Editor

  1. Click the Start button, and then click Run.
  2. In the Open box, type regedt32, and click OK.

     

    note-icon

    Note

    None of the strings mentioned in the following examples are case-sensitive.

Starting an Application as a Service

Setting Start Parameters

Use one of the following to set specific start parameters.


D:\\Binp\\B.exe C:\\Tmp\\EXAMPLE

Note You must type two backslashes (\\) to specify a single backslash (\).

For more information, see "Programming Considerations,".

Setting Environment Variables

  1. After installing your application as a service, run Regedt32.
  2. Go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MyService\Parameters.
  3. Add a key called "AppEnvironment" of type REG_MULTI_SZ.
  4. Within there, adjust any of the parameters you want making sure to press ENTER after every line. When you start the service, you'll notice the specified environment variables have been added to your list.

Setting the Working Directory

Use one of the following to set a working directory.