Hello All, I'm having some trouble getting this script to run as a service, any and all help is appreciated:
#!c:\perl\bin use Win32::Process; use Win32; package PerlSvc; our $Name = 'CDcontrol'; ofur $DisplayName = 'CDcontrol Service'; $dir = ""; $file = ""; $pid = ""; $c = 1; $eproc = 0; $dproc = 0; sub Startup { # here's where your startup code will go main::Init(); while(ContinueRun()) { main::LogIt(localtime()."\n") unless (time() % 30); sleep(1); } # end while loop } # end startup sub sub install { use Win32::TieRegistry(Delimiter=>"/", ArrayValues=>0); $Registry->Delimiter("/"); $svcKey = $Registry->{"LMachine/System/CurrentControlSet/Services/"}; $thisKey = $svcKey->{"CDcontrol/"}; $thisKey->{"/Start"} = ["0x0002","REG_DWORD"]; } # end of Install subroutine package main; sub Init { sub ErrorReport { print Win32::FormatMessage( Win32::GetLastError() ); } # end sub Error report while (1) { ## Look at contents of the cdrom drives D and E for $drives(d,e) { $dir = "$drives:"; print "this is dir $dir\n"; opendir (CDROM1, "$dir") || &ErrorReport; while (defined($file = readdir(CDROM1))) { if ($file =~ /mpg/) { print "This is directory $dir and this is the file $file in first section\n"; $vals{"$dir"} = "$file"; sleep(2); $c++; } else { print "This file is not a mpg $file\n"; $eject = `c:\\eject\\eject.exe $dir`; sleep(2); } # end else statement } # end while loop closedir(CDROM1); } # end for loop while ( ($dir, $file) = each(%vals) ) { print "$dir\n"; if ($dir eq "d:") { $dproc = 1; $ddir = $dir; $dfile = $file; } elsif ($dir eq"e:") { $eproc = 1; $edir = $dir; $efile = $file; } print "This is directory $dir and this is the file $file in first sub\n"; } # end while loop print "Dproc is $dproc and Eproc is $eproc\n"; #################### Start the WMP for the D: Drive if ($dproc > 0) { Win32::Process::Create($dprocess, "c:\\Program Files\\Windows Media Player\\mplayer2.exe", "mplayer2.exe /open $ddir/$dfile", 0, NORMAL_PRIORITY_CLASS, ".") || die ErrorReport(); $dpid =$dprocess->GetProcessID(); $dprocess->GetExitCode($xid); $dpids{"$ddir"} = $dpid; sleep(4); } #################### Start the WMP for the E: Drive if ($eproc > 0) { Win32::Process::Create($eprocess, "c:\\Program Files\\Windows Media Player\\mplayer2.exe", "mplayer2.exe /open $edir/$efile", 0, NORMAL_PRIORITY_CLASS, ".") || die ErrorReport(); $epid =$eprocess->GetProcessID(); $eprocess->GetExitCode($xid); $epids{"$edir"} = $epid; sleep(4); } ############################ Debug print statements print "This is dproc $dproc before if statement\n"; print "This is eproc $eproc before if statement\n"; ############################ ######################### Conditionals to wait for the WMP ######################### process to end and eject the CDROM if ($dproc) { print "This is dproc $dproc\n"; $dprocess->Wait(INFINITE); sleep(4); print "should be ejecting $ddir\n"; $eject = `c:\\eject\\eject.exe $ddir`; $dproc = 0; delete($vals{"$ddir"}); sleep(4); } if ($eproc) { print "This is eproc $eproc\n"; $eprocess->Wait(INFINITE); sleep(4); print "should be ejecting $edir\n"; $eject = `c:\\eject\\eject.exe $edir`; $eproc = 0; delete($vals{"$edir"}); sleep(4); } } # end of the c loop } # end of the INIT Sub This e-mail message is for the sole use of the intended recipient(s) and may contain confidential and/or privileged information. Any review, use, disclosure or distribution by persons or entities other than the intended recipient(s) is prohibited. If you are not the intended recipient, please contact the sender by reply and destroy all copies of the original message. Thank you. WordWave, Capturing the Power of the Spoken Word http://www.wordwave.com _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs