Customer Login

Creating NT services PDF Print E-mail

Visual DialogScript can create programs that run as a service under Windows NT family operating systems. Services are programs that start when Windows starts, and stop when Windows closes down. They do not close when a user logs out, and do not require a user to be logged in. Since a service is designed to run without any interaction by a user, they are usually developed as console applications. Any information or error messages that they produce should be written to a log file.

Creating a Windows NT service is the same as creating a normal program using VDS, except:

  • The program will be a console application. The console is used to display informative messages when the service is installed, started and stopped using the command line switches.
  • The service process itself cannot receive any command line arguments.
  • The program should not create a window or display dialog or message box, nor should it launch another program that does so, unless it is installed as an interactive service and it has determined that a desktop is present at the time for the window to be displayed on. (The function @winexists(#ProgMan) returns True in this case.) .
  • Error messages and other information should be written to a log file.
  • OPTION ERRORTRAP should be used so that any error message can be trapped and written to a log and does not result in displaying an unexpected message box.
  • The program should not close if it receives a CLOSE event. VDS 5 services will be terminated abruptly, so they should not keep any files open and should immediately write any data it generates to a file or the registry. VDS 6 services receive a special STOP event when they are terminated or stopped. This event must be used to close down the program cleanly and then stop.
  • The program must contain version information to identify itself to Windows. The string 'Original Filename' is used as the service name and 'File Description' is used as the service description (which is displayed in the Services management console).

 Services created using VDS have built-in support for installing and starting them from the command line, using the following switches:

  • -install
     Installs the program as a service, using the default settings. These may be changed by following this switch by either of these arguments:
    • MANUAL
       The service must be started manually and will not start automatically when Windows starts. If this argument is not present, the service will always start automatically.
    • INTERACTIVE
       The service will be visible to logged-in users, and may display a window or launch other processes that create windows, if a user is logged in. Note: Interactive services are now deprecated as they are considered by Microsoft to be a security risk. They may not be supported in later versions of Windows. If this argument is not present, the service will be non-interactive.
  • -start
     Starts the service running.
  • -stop
     Stops the service.
  • -pause
     Pauses the service [VDS 6 services only]
  • -resume
     Resumes the service [VDS 6 services only]
  • -remove
     Stops the service if it is running, and then removes it from the list of installed services.
     
Last Updated ( Thursday, 20 December 2007 )