use Win32::Daemon; # Tell the OS to start processing the service... Win32::Daemon::StartService(); print "Waiting...\n"; # Wait until the service manager is ready for us to continue... print "SERVICE_NOT_READY " . SERVICE_NOT_READY . "\n"; print "SERVICE_STOPPED " . SERVICE_STOPPED . "\n"; print "SERVICE_RUNNING " . SERVICE_RUNNING . "\n"; print "SERVICE_PAUSED " . SERVICE_PAUSED . "\n"; print "SERVICE_START_PENDING " . SERVICE_START_PENDING . "\n"; print "SERVICE_STOP_PENDING " . SERVICE_STOP_PENDING . "\n"; print "SERVICE_CONTINUE_PENDING " . SERVICE_CONTINUE_PENDING . "\n"; print "SERVICE_PAUSE_PENDING " . SERVICE_PAUSE_PENDING . "\n"; while( SERVICE_START_PENDING != Win32::Daemon::State() ) { sleep( 1 ); print Win32::Daemon::State() . "\n"; } print "Running...\n"; # Now let the service manager know that we are running... Win32::Daemon::State( SERVICE_RUNNING ); # Okay, go ahead and process stuff... unlink( glob( "c:\\temp\\*.tmp" ) ); # Tell the OS that the service is terminating... Win32::Daemon::StopService();