Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

A GUI program to configure XYNTService

0.00/5 (No votes)
4 Jul 2007 1  
The easiest and most flexible way to use XYNTService.

What is XYNTService

Maybe you have heard about XYNTService. It is described in my most popular CodeProject article. It is a free Windows service that can be used to run other programs.

For example, say you have a program on a server that processes certain tasks in the background. You want this program to be started automatically when the server boots up, and to run continuously with nobody logged on. All you need to do to make this happen is configure XYNTService to start your program. XYNTService will even restart your program if it is dead for some unknown reason.

To configure XYNTService, you need to work with the XYNTService.ini file. This file defines all of the programs to be started and monitored by XYNTService. If you need more than one Windows service to run different sets of programs, you can copy XYNTService.exe and XYNTService.ini into a different folder, modify XYNTService.ini -- to change the ServiceName property and the list of programs it should start, etc. -- and then run the following commands to install and start the new service:

XYNTService.exe -i
XYNTService.exe -r MyNewServiceName

In this article, I am going to introduce a GUI program to help configure XYNTService. Using this program, you can install/uninstall, start/stop and modify all properties. This includes the list of programs run by XYNTService. In other words, you won't need to manually edit the XYNTService.ini file. By the way, if you like this program, please remember to vote a 5 for me :-).

Configure XYNTService using XYNTServiceWrapper.exe

Since this is a GUI program, I am going to demonstrate its use through pictures. The executable can be located anywhere on your computer. You also need to copy XYNTService.exe and its INI file onto your computer. You will see the following window after starting the program:

Selecting the service executable. First, use the "Browse" button to locate and select the executable for XYNTService. Note that it is possible to rename the XYNTService.exe file. If you named it as MyService.exe, then the corresponding INI file will be MyService.ini and the log file will be MyService.log. After you have found the executable, some buttons on the screen will be enabled, depending on whether the service is already installed and/or running. The picture below shows the window after you have selected the service executable:

Changing the name of the service. As you can see, the "Install" button is enabled. This means that the service is not installed yet. You can give it a different name by changing the "Service Name" field in the above window.

Note that notepad.exe and wordpad.exe are listed in the "List of programs to be started by this service" box. These programs come from the existing INI file in the same folder as the service executable. When the service is starting, it will run these programs in the same order as the program list shown here. When the service is shutting down, it will terminate these programs in the reverse order. If you click the "Add" button or the "Edit" button after selecting a program from the list, a dialog box will pop up as shown in the picture here:

Changing an existing program or adding a new program. You can change the executable of the program by using the "Browse" button or simply typing the new program into the "Command Line" field. Note that you can also supply command line arguments for the program. The "Working Directory" field will be used by the program when it is started by the service. The default will be the path of the folder where the executable resides. You can enter any valid folder path.

If you check the "Show user interface" box, then the program will appear on the desktop if it is started by the service. Otherwise, it will be hidden. The "Restart the process if it is dead" box can be checked if you want the service to restart your program. The next two fields are two numbers that are used by the service. The first is the number of milliseconds that the service will pause before starting the next program in the program list. The second is the number of milliseconds the service will pause before forcefully terminating the current program.

These two numbers are useful if your programs depend on each other. For example, your second program can only work if your first program has done some initialization. In this case, you can set the number to be 2000, making the service wait for 2 seconds before it starts the second program. Clicking the "Save" button will make the change for the program you selected. If you clicked the "Add" button to open the dialog box, it will add a new program to the program list. Now back to the main window.

Changing the order in the program list. You can select a program from the program list and use the "Up" or "Down" button to move it within the list. The programs will be started by the service according to the order they appear in the program list.

Restarting programs in the list. If you click the "Check process status" button on the main window, an additional field will appear to allow you to enter a number. This is the number of seconds the service will wait each time before it checks the status of the programs it has started. If the service decides that a program is dead, it will restart the program if the "Restart the process if it is dead" box is checked for that program.

Installing and starting the service. Now you can click the "Install" button and then the "Start" button to install and start the service.

The "Install" button is disabled now because the service is already installed. The "Uninstall" and "Start" buttons are disabled because the service is running. If you open the Windows TaskManager, you should see that the programs in the program list are started by the service.

Bouncing a program in the program list. If you select a program from the list and click the "Bounce" button, the service will stop the corresponding program and restart it.

Stopping and uninstalling the service. If you click the "Stop" button, the service will be stopped. As a result, all of the programs in the list will also be stopped. After stopping the service, the "Uninstall" and "Start" buttons will be enabled again. Clicking the "Uninstall" button will uninstall the service.

Exiting the program. Finally, the "Save" button will cause your changes to be saved in the corresponding INI file so that the next time you open this program you will see the latest information. The "Install" button and the "Start" button will also save your changes. To quit the program, click the "Quit" button, of course.

View log file. Clicking the "View Log" button will open a dialog box where log file entries are parsed into a list box in reverse order: the most recent entries will be displayed first. If you just want to see the error messages, click the "Show Error" button on this dialog and all the other messages will be filtered out.

Limitations

Currently, the program does not handle the task of running the service from an account other than "Local System." You will have to manually configure the service to run with a different user account. You can do this using the "Administrative Tools" or the "Control Panel." If you install/uninstall and start/stop the service outside of this program while it is running, then the buttons won't be enabled/disabled correctly.

For those who wonder, this program does not change the way XYNTService works. It still gets configuration information from the corresponding INI file. Each time you save your changes with this program, the corresponding INI file will be updated. There may still be cases when you need to manually edit the INI file, but all the normal cases should have been taken care of by this GUI program. Finally, some new features such as the "View Log" button will not work with old versions of XYNTService.

Final note

The application is written with MFC, Visual Studio 6.0. This is the first major GUI application I have written since I started doing web development more than 4 years ago. It sure brings back a lot of memories. Thanks for reading my articles.

History

  • 1 March, 2006 -- Original version posted
  • 7 April, 2006 -- Article updated
  • 4 July, 2007 -- Download and images updated
  • 22 Feb, 2008 -- included a recompiled version of XYNTService.exe to stop bogus anti-virus warnings

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here