Running VDF programs as Windows Services

From DataFlex Wiki
Jump to navigationJump to search

A Visual DataFlex program can be run as a Windows™ Service. This option allows the creation of programs, which in general will have no user-interface component, to run in the background and perform tasks in a continuous or scheduled manner.

Using the SrvAny Utility

Instructions for using this are available from Microsoft Support, while the software, originally provided as part of a Microsoft Resource Pack, is widely available to download (here is one example, but a quick Google will find many).

To summarise, the following steps have to be taken to create and customise any program (although our interest is obviously in VDF programs) to run as a Windows Service.

  1. Unzip the contents of the file srvany.zip into a suitable location. There are two executable files - instsrv.exe and srvany.exe - and a Windows™ Write file - srvany.wri - describing usage.
  2. At a Windows™ command prompt type the command:
    {path-to-srvany}\instsrv.exe {YourServiceName} {path-to-srvany}\srvany.exe
  3. Using RegEdit.exe (or RegEdit32.exe), open the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\{YourServiceName} key
  4. Within that create a new key called "Parameters"
  5. Within that Parameters key, create a new string value (REG_SZ) called "Application" and in it place the full path and filename of the VDF program to be executed
  6. Optionally, create within Parameters an "AppParameters" string value which will contain the parameters to be passed to the program
  7. Optionally, create within Parameters an "AppDirectory" string value which will contain the full path of the directory the application should run in
  8. Optionally, under the YourServiceName key create a string value "DisplayName" which will contain the display name of the service within the Control Panel Services applet
  9. Optionally, under the YourServiceName key create a string value "Description" which will contain the verbose description of the service within the Control Panel Services applet
  10. Optionally, under the YourServiceName key create a multi-string (REG_MULTI_SZ) value called "DependOnService" which will contain a list of the services that your service depends on having running (a local database service for instance)
  11. You should then be able to use the Control Panel Services applet to configure such things as the Start type (Automatic, Manual, Disabled), the account to run as and so on (these can also be done directly in the Registry, but it is both easier and safer to use the applet)

If configured to start automatically, your service will then run automatically when Windows is started.


With thanks to this article on VDF Guidance by Bob Worsley.