O' Holy Monks ***** PLEASE PLEASE HELP *****

I have installed many printers on many remote WinXP PCs incorrectly via a Perl script working as shell around the PSEXEC utility. I need to remove them all now. All those printers were installed from \\print_server\printer_name remote share. In addition, all appear in the printers and faxes folder on the WinXP PC (and they all show as inaccessible). None of these printers been shared locally (so I cannot use NetResource).

I tested this script to remove a printer; however, the registry entries do get removed but the printer icons still remains visible in the Printers and Faxes folder.
use Win32::TieRegistry; $printerKey= $Registry->{"HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Control\\P +rint\\Printers\\"} or die "Can't read Printers key: $^E\n"; @printers= keys( %{$printerKey} ); foreach $printer (@printers) { print $printerKey->{$printer."\\Name"}."\n"; if ($printerKey->{$printer."\\Name"}=~ /\\\\printer_server\\/) { delete $printerKey->{$printer."\\Name"}; } }
the script I used to add the printer (for all its damn worth) was this;
#!c:/perl/bin/perl.exe -w use strict; use vars qw/%data/; $data{printer_server}= "\\\\print_server\\"; $data{PSEXEC}="\\\\Remote_host\\C\$\\Tools\\PSTools\\PSEXEC\\psexec.ex +e"; $data{usr}= "XXX\\Blackadder_ad"; $data{pw}= "Supernatural2005"; $data{command}= " cmd.exe /c start"; open (LST, "$ARGV[0]") || die "File Name => $ARGV[0] $!\n"; chomp (@{$data{host_names}} = <LST>); for (@{$data{host_names}}) { print "$_ : "; &install_printers($_); } sub install_printers { my ($target) = @_; my $const = 'snp'; my $switches = ' -i -d -u '; print "$target : "; if ($target =~ /^SN01/) { print " First Flr Printers, "; for (1..9) { $_ = '10'.$_; `$data{PSEXEC} \\\\$target -i -d -u $data{usr} -p $data{pw} c +md /c start $data{printer_server}$const$_`; print "$const$_,"; } } if ($target =~ /^SN02/) { print " Second Flr Printers, "; for (0..7) { $_ = '20'.$_; `$data{PSEXEC} \\\\$target -i -d -u $data{usr} -p $data{pw} c +md /c start $data{printer_server}$const$_`; print "$const$_, "; } } print "\n"; } print "\n____________End of List____________\n";
Your help is highly appreciated (a code example triple so)

I have just downloaded Win32::Printer module (which I never used before) and see if there is anything in there that can help me.

Thanks
Blackadder

In reply to Removing printers from remote WinXP PC by blackadder

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.