Thank you for your
excellent program. It is truly a work of art and will make life easier
once I have it customized for my site and get all the site specific
configuration bugs worked out.
I wanted a way to
specify printers during the initial dialog and have them installed as part of
the process. I made some modifications to install.pl and created a
printers.pl script that I placed in the "site" folder to accomplish this
task. I keep a text file in "site" that contains a list of full unc paths
to my various printers. During the initial dialog, this list is pulled up
and the printer install choices are displayed as a multi-choice dialog. If
any printers are selected, they are stuffed into a .vbs file that is run during
postinst.bat. The vbs file contains Windows Script Host code that installs
the printers.
I would like to
share my code in case any one else might find this to be useful. Is there
any reason that a generic printer dialog is not in the initial
script? Am I off base and missing some important point? Would
anyone else find this feature useful?
###########################
Changes made to
Install.pl
###########################
Added the following
lines to "sub create_postinst_bat ()". The code is placed right after the
section "# NTP servers"
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
#
Printers
if (-e
"c:/netinst/printset.vbs") {
push @postinst_lines, "call c:\\netinst\\printset.vbs";
}
push @postinst_lines, "call c:\\netinst\\printset.vbs";
}
Added the following
lines after "# Create C:\netinst and subdirectories." and before "# Create
unattend.txt file."
----------------------------------------------------------------------------------------------------------------------------------------------------------------
# Call site-specific
printer setup dialog.
my $print_conf = 'z:\\site\\printers.pl';
my $print_conf = 'z:\\site\\printers.pl';
if (-e $print_conf)
{
my $pr_result = do $print_conf;
$@
and die "do $print_conf failed: $@";
defined $pr_result
or die "Could not do $print_conf: $^E";
}
my $pr_result = do $print_conf;
$@
and die "do $print_conf failed: $@";
defined $pr_result
or die "Could not do $print_conf: $^E";
}
Added the following
lines so that a new option would be pushed into @edit_choices. The code
was placed after the push of "$doit" into @edit_choices.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
my $printsetup =
$u->{'_meta'}->{'printsetup'};
defined $printsetup
and push (@edit_choices,
"Edit $printsetup (will be run by $postinst)"
=> $printsetup);
defined $printsetup
and push (@edit_choices,
"Edit $printsetup (will be run by $postinst)"
=> $printsetup);
###########################
Contents of
printers.pl
###########################
sub
create_print_setup () {
my $netinst = 'c:\\netinst';
my @print_lines;
my $print_string = $u->{'_meta'}->{'printers'};
my @printers = split /;/, $print_string if ($print_string);
if (scalar @printers > 0) {
push @print_lines,
'Set WshNetwork = CreateObject("WScript.Network")';
foreach (@printers) {
push @print_lines, "WshNetwork.AddWindowsPrinterConnection \"$_\"";
}
}
if (scalar @print_lines > 0) {
open (OUT, ">$netinst\\printset.vbs");
print "Creating $netinst\\printset.vbs...";
foreach (@print_lines) {
print OUT "$_\n"
}
print "done.\n\n";
}
return 'c:\netinst\printset.vbs';
}
my $netinst = 'c:\\netinst';
my @print_lines;
my $print_string = $u->{'_meta'}->{'printers'};
my @printers = split /;/, $print_string if ($print_string);
if (scalar @printers > 0) {
push @print_lines,
'Set WshNetwork = CreateObject("WScript.Network")';
foreach (@printers) {
push @print_lines, "WshNetwork.AddWindowsPrinterConnection \"$_\"";
}
}
if (scalar @print_lines > 0) {
open (OUT, ">$netinst\\printset.vbs");
print "Creating $netinst\\printset.vbs...";
foreach (@print_lines) {
print OUT "$_\n"
}
print "done.\n\n";
}
return 'c:\netinst\printset.vbs';
}
$u->comments
('_meta', 'printers') =
['Printers to be installed'];
['Printers to be installed'];
$u->{'_meta'}->{'printers'} =
sub {
my $printers = "z:/site/printers.txt";
my @print_array;
if (-e $printers) {
open (IN, "$printers") || warn "Could not open file: $!";
while (<IN>) {
chomp;
push @print_array, $_;
}
close (IN);
@selected_printers = multi_choice ('Choose printers to setup.',
@print_array);
return join ';', @selected_printers;
}
};
$u->{'_meta'}->{'printsetup'} =
\&create_print_setup;
############################
Sample contents of
printers.txt
############################
#######################
Notes
#######################
printers.pl and
printers.txt both go in "install\site"
The local admin
account on the client must have the same password as the local admin
account on the print server or else the .vbs script will fail (won't be able to
access the print server to setup the printer).
The printers must be
setup on the print server such that they can be installed by just calling the
full unc path to the printer from a command line or run
dialog.
Again, I thank you
for your time and hard work on this project.
Sincerely,
Tyler
Hepworth
Computer
Specialist
Nature's Sunshine
Products
