I have a script that produces status information for server queues. When I execute the script from the server command line I obtain the desired results. When the script is executed unattended by the local account of servers (using AutoExNT from Win2k resource kit) service the local profile of the account used to executes the script gets locked (unable to delete the profile). This would indicate that something is still open and the profile cannot be closed properly by the system.
I would appreciate if someone could have a look and let me know if there is something obvious I'm missing. The code in question is should only be the of the "*** SUB HW_INV ***" # *** MODULES *** use DBI; use DBD::mysql; use Socket; use Sys::Hostname; use Win32::OLE qw(in with); # *** VARIABLES *** my $count = 0; my $host = hostname(); my $db = 'DBI:mysql:testDB:test.domain.com; my $username = 'user'; my $pass = 'password'; # *** CONSTANTS *** my %detectedErrorState = ( "0" => [ "Unknown" ], "1" => [ "Other" ], "2" => [ "No error" ], "3" => [ "Low paper" ], "4" => [ "No paper" ], "5" => [ "Low toner" ], "6" => [ "No toner" ], "7" => [ "Door open" ], "8" => [ "Jammed" ], "9" => [ "Offline" ], "10" => [ "Service requested" ], "11" => [ "Output bin full" ]); my %Status = ( "1" => [ "Other" ], "2" => [ "Unknown" ], "3" => [ "Idle" ], "4" => [ "Printing" ], "5" => [ "Warmup" ], "6" => [ "Stopped printing" ], "7" => [ "Offline" ]); # *** MAIN *** @ctime = localtime(time); $day = $ctime[3]; $month = $ctime[4] + 1; $year = $ctime[5] + 1900; $newdate = sprintf("%s-%02s-%02s",$year,$month,$day); #printf("$newdate\n"); &hw_inv; #print ("$printer_server: ($count) Printer Alerts. Done.\n"); #exit(0); exit; # *** END MAIN *** # *** SUB HW_INV *** sub hw_inv { # Gather Printer Status my $WMI = Win32::OLE->new('WbemScripting.SWbemLocator') || die "Cannot access WMI on local server: ", Win32::OLE->LastError; my $Services = $WMI->ConnectServer($host) || die "Cannot access WMI on remote machine: ", Win32::OLE->LastError; # Gather Computer System Information my $printer_set = $Services->InstancesOf("Win32_Printer"); my $dbh = DBI->connect($db, $username, $pass) || die $DBI::errstr,"\n"; foreach my $printer (in($printer_set)) { my $printer_name = $printer->{'Caption'}; my $printer_desc = $printer->{'Description'}; my $printer_error = $printer->{'DetectedErrorState'}; my $printer_driver = $printer->{'DriverName'}; my $printer_jobs = $printer->{'JobCountSinceLastReset'}; my $printer_location = $printer->{'Location'}; my $printer_state = $printer->{'PrinterState'}; my $printer_status = $printer->{'PrinterStatus'}; my $printer_stat = $printer->{'Status'}; my $printer_server = $printer->{'SystemName'}; if ($printer_error != 0) { $count++; my $sql = $dbh->prepare("INSERT INTO SUPPORTPRINTER (Printer, Jobs, Message, Status, Model, Executed) VALUES ('$printer_name',$printer_jobs,'$detectedErrorState{$printer_error}[0]','$St atus{$printer_status}[0]','$printer_driver','$newdate');"); $sql->execute(); } if (($printer_error == 0) && ($printer_status == 1)) { $count++; my $sql = $dbh->prepare("INSERT INTO SUPPORTPRINTER (Printer, Jobs, Message, Status, Model, Executed) VALUES ('$printer_name',$printer_jobs,'$detectedErrorState{$printer_error}[0]','$St atus{$printer_status}[0]','$printer_driver','$newdate');"); $sql->execute(); } } $dbh->disconnect(); } # *** END HW_INV *** Frank Pikelner _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs