Search
Windows 7

Advanced Windows 7 Programming : Working in the Background - DEVELOPING TRIGGER-START SERVICES (part 7)

Published 2 min readBy Programming4us Editorial Team

5.3. Performing the Telnet Test

At this point, you have Telnet installed and configured, and the service is installed and configured. Follow these steps to test the functionality of the trigger-start service:

  1. Open the Event Viewer console in the Administrative Tools folder of the Control Panel. You'll see the Event Viewer window.

  2. Open the Event Viewer\Windows Logs folder.

  3. Right-click the System log entry and choose Clear Log from the Context menu. You'll see an Event Viewer dialog box.

  4. Click Clear to clear the events in the Event Viewer.

  5. Open the Services console in the Administrative Tools folder of the Control Panel. Right-click the Telnet entry and choose Start from the Context menu. The Telnet service will start. Starting the Telnet service opens Port 23. You can verify this fact by typing NetStat –a at the command prompt and pressing Enter. The NetStat utility shows that the system is listening on Port 23, as shown in Figure 11. (Notice the 0.0.0.0:23 address entry on the first line of the output — the :23 part of the entry signifies Port 23.)

  6. Wait at least 60 seconds. Windows doesn't guarantee that a trigger-start service will respond immediately to an event. In fact, you'll find that the documentation makes a vague reference to a 60-second response time, but Microsoft never makes it very clear. Depending on system load, a trigger-start service may not even respond within 60 seconds, but it will respond.

  7. Choose Action => Refresh. You'll see that TriggerStartService has started. It will remain started as long as the Telnet service is running, as shown in Figure 12.

    Figure 11. Use the NetStat utility to determine when a particular port is open.

    Figure 12. Windows starts TriggerStartService as needed to respond to port events.

  8. Right-click the Telnet service and choose Stop from the Context menu. The Telnet service will stop. Verify that Port 23 is no longer open by typing NetStat –a at the command prompt and pressing Enter.

  9. Wait at least 60 seconds.

  10. Choose Action => Refresh. You'll see that TriggerStartService has stopped.

  11. In the Event Viewer, make sure the System log is selected and choose Action Refresh. You'll see a series of event log entries like those shown in Figure 1.

    Figure 13. The exercise you just completed creates a number of event log entries.

  12. Beginning with the oldest entry, view the entries one at a time. You'll see the sequence of events that you've just tested with this procedure. The event log will tell you that Telnet started, then TriggerStartService. One of the entries will tell you that Port 23 has opened. Keep following the entries, and you'll eventually see one where Port 23 closes after the Telnet service stops. Notice that the trigger-start service starts and stops as the port opens and closes, but that Windows doesn't act immediately — the action always requires some amount of time.

At this point, you might want to uninstall TriggerStartService. To perform this task, type InstallUtil /U TriggerStartService.EXE and press Enter.