Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello all, I'm trying to add a service to start an app. automatically on boot-up. This is my code : ______________________________________________________________
use strict; my $Registry; use Win32::TieRegistry ( TiedRef=>\$Registry, Delimiter=>"/" ); my $CAP_HOME = Win32::GetCwd(); $CAP_HOME =~ s/\\bin\S*//; $Registry->{"LMachine/System/CurrentControlSet/Services/CapSync/"}= { "/DisplayName" => [ "CapSync", "REG_SZ"], "/ErrorControl" => [ "0x0001", "REG_DWORD"], "/ImagePath" => [ "$CAP_HOME\\bin\\Start_CapSync.exe", "REG_EXPAND +_SZ"], "/ObjectName" => [ "LocalSystem", "REG_SZ"], "/Start" => [ "0x0002", "REG_DWORD"], "/Type" => [ "0x0110", "REG_DWORD"], } or die "Can not create services entry\n";
___________________________________________________________ The entry is made into services and looks correct, but when the service control manager tries to start the service, it fails. Actually it times out w/ the following in the event log entry. "The CapSync service failed to start due to the following error. The service did not respond to the start or control request in a timely fashion" Does anyone have a clue to what might be causing this? Start_CapSync is a simple executable that just sends me email right now until I can get this working properly. Thanks, Eric

Replies are listed 'Best First'.
(tye)Re: Trying to add a service in win32 environment
by tye (Sage) on Oct 11, 2000 at 18:54 UTC

    "The CapSync service failed to start due to the following error. The service did not respond to the start or control request in a timely fashion" Does anyone have a clue to what might be causing this? Start_CapSync is a simple executable that just sends me email right now until I can get this working properly.

    An NT service must follow a specific interface. To have an arbitrary program work as an NT service you can use a program from the NT Resource Kit ("srvany", or something close to that). It responds to the service control messages and just runs your program for you. If you have problem finding or setting up this program, then let us know.

            - tye (but my friends call me "Tye")
One more time Re: Trying to add a service in win32 environment
by bravos_1 (Initiate) on Oct 11, 2000 at 04:44 UTC
    Sorry... let's try it again. Code follows:
    use strict; my $Registry; use Win32::TieRegistry ( TiedRef=>\$Registry, Delimiter=>"/" ); my $CAP_HOME = Win32::GetCwd(); $CAP_HOME =~ s/\\bin\S*//; $Registry->{"LMachine/System/CurrentControlSet/Services/CapSync/"}= { "/DisplayName" => [ "CapSync", "REG_SZ"], "/ErrorControl" => [ "0x0001", "REG_DWORD"], "/ImagePath" => [ "$CAP_HOME\\bin\\Start_CapSync.exe", "REG_EXPAND +_SZ"], "/ObjectName" => [ "LocalSystem", "REG_SZ"], "/Start" => [ "0x0002", "REG_DWORD"], "/Type" => [ "0x0110", "REG_DWORD"], } or die "Can not create services entry\n";