Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printer install HTA help

Status
Not open for further replies.

GuruGabe

IS-IT--Management
Mar 6, 2012
5
US
I have a HTA that installs IP printers as local printers for our domain network. I would to modify it so that any of our techs can type in a message box a list of remote computers to install selected printer on so that they do not have to run script on individual machines.
Plus I would like to know if at all possible if I can add to it to install network shared printers as local as well. (Possibly Printer port: \\computer\shared printer). Any help would be appreciated or if you have other suggestions

<html>
<title>Printer Installation Utility</title>
<HTA:APPLICATION
ID="Orphan"
APPLICATION="YES"
APPLICATIONNAME="Printer Installation Utility"
SCROLL="no"
ICON="panther.ICO"
CONTEXTMENU="no"
SYSMENU="no"
SHOWINTASKBAR="yes"
BORDER="thick"
BORDERSTYLE="complex"
version="1.0"
SINGLEINSTANCE="no"
WINDOWSTATE="normal">
<head>
<style type="text/css">
body {
font: 80%/1.5 arial, helvetica, sans-serif;
color: white;
background-color: #53769E;
text-align: left;
}

h1 {
font-size:1.5em;
font-family: Verdana, sans-serif;
color: #333;
margin: 5px;
padding: 0;
letter-spacing: -1px;
}

h2 {
font-size:1.2em;
font-family: helvetica, sans-serif;
color: #FFFFFF;
margin: 0 0 0.3em;
padding: 0;
}

.section {
width:95%;
padding: 3px;
margin: 10px 10px 10px 15px;
}

.section p {
color:#FFFFFF;
}

.section label {
color:#FFFFFF;
}
.section ul {
list-style-type: none;
}

/* BUTTONS */

button{
display:block;

float:right;

margin:0 0px 0 5px;
background-color:#f5f5f5;
border:1px solid #dedede;
border-top:1px solid #eee;
border-left:1px solid #eee;

font-family:"Lucida Grande", Tahoma, Arial, Verdana, sans-serif;
font-size:100%;
line-height:130%;
text-decoration:none;
font-weight:bold;
color:#565656;
cursor:pointer;
padding:5px 10px 6px 7px; /* Links */
}

button{
width:auto;
overflow:visible;
padding:4px 10px 3px 7px; /* IE6 */
}

button[type]{
padding:5px 10px 5px 7px; /* Firefox */
line-height:17px; /* Safari */
}

*:first-child+html button[type]{
padding:4px 10px 3px 7px; /* IE7 */
}

button img, a img{
margin:0 3px -3px 0 !important;
padding:0;
border:none;
width:16px;
height:16px;
}

/* END OF BUTTONS */

/* I use this method from CSS Play ( You may use it for commercial use but a donation is requested, see the site for details */

.xsnazzy h1, .xsnazzy h2, .xsnazzy p {margin:0 10px; letter-spacing:-1px; padding:0;}
.xsnazzy h1 {font-size:1.5em; color:#fff;}
.xsnazzy h2 {font-size:2em;color:#06a; border:0;}
.xsnazzy p {padding-bottom:0.5em;}
.xsnazzy h2 {padding-top:0.5em;}
.xsnazzy {background: transparent; margin:5px 1em 0px 0em; }

.xtop, .xbottom {display:block; background:transparent; font-size:1px;}
.xb1, .xb2, .xb3, .xb4 {display:block; overflow:hidden;}
.xb1, .xb2, .xb3 {height:1px;}
.xb2, .xb3, .xb4 {background:#80D4FE; border-left:1px solid #08c; border-right:1px solid #08c;}
.xb1 {margin:0 5px; background:#08c;}
.xb2 {margin:0 3px; border-width:0 2px;}
.xb3 {margin:0 2px;}
.xb4 {height:2px; margin:0 1px;}

.xboxcontent {display:block; background:#80D4FE; border:0 solid #08c; border-width:0 1px;}

#footer {
clear: both;
display: block;
margin: 75px auto auto auto;
padding: 0 0 20px 0;
}
#footer p {
color: #C2C2C2;
font-size: 0.7em;
}

</style>

<script language="vbscript"></script>
</head>
<body>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="33%" valign="top"><img src="panther.gif" alt="Panther" width="90" height="72"></td>
<td width="34%" valign="top">
<font size="6" color="white"><b><center>Independent School District</b></center></font>
</td>
<td width="33%" align="right" valign="top"><img src="panther.gif" alt="Panther" width="90" height="72"></td>
</tr>
</table>
<br>
<br>

<form id="inputform" name="inputform">

<input id=quit button class="button" type="button" value="Quit" name="quit_button"
onClick="Window_Onclose()" title="Quit Batch User Manager">
<font face="Verdana" ID=spaces></Font>
</table><Table border="0" Width="100%">

<!--Here -->


<!-- Here -->
<hr><strong>Branch Location:</strong>
<div ID=location></div><td>
<div ID=listprinters></div>

<tr><td> <div ID=Install></div>
<tr><td> <div ID=SelectAll></div>

</td>
</form>
</body>
</html>
<script language="vbscript">
width = "1000"
height = "600"
' This moves the window to the middle of the screen
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor WHERE DeviceID='DesktopMonitor1'")
For Each objItem in ColItems
intHorizontal = objItem.ScreenWidth
intVertical = objItem.ScreenHeight
Next
intLeft = (intHorizontal - width)/2
intTop = (intVertical - height)/2
window.resizeTo width,height
window.moveTo intLeft, intTop

dim prnlist(50,2)
DIM Printers(100,11):DIM X
DIM strbranch
DIM prnchoice
Set objShell = CreateObject("Wscript.Shell")

STRLOCATIONS="Select your location,Alamo,Apache,Intermediate,Middle School,High School,Butz,Auto Tech,Food Services,Central Office,Bus Barn / Maintenance,Special Services,Technology"
'use STRLOCATIONS to list the different locations. Printers will be categorized according to location
' be sure to leave the "Select your location" in the list.

' ******* addprint function syntax is as follows:
' addprint ("portname,portprotocol,IP Address,Port Number,Port Queue,enable SNMP,Driver Name,driver path,inf path&name,printer name,location")
' ******* The following is where we add all the printers. The addprint function will add the printer to the array
' ******* Follow the above format.


' ******* Technology
addprint("IP_*.*.133.210,1,*.*.133.210,9100,,FALSE,HP Universal Printing PCL 6,\\*.*.200.14\path to inf,\\*.*.200.14\path to inf\hpcu118u.inf,Technology - HP Color LaserJet CP4005,Technology")

' ******* Special Services

addprint("IP_*.*.130.220,1,*.*.130.220,9100,,FALSE,Xerox WorkCentre 238,\\*.*.200.14\path to inf,\\*.*.200.14\path to inf\XRBA55PCL.INF,Special Services - Xerox WorkCentre 238,Special Services")


' ******* Bus Barn / Maintenance


' ******* Central Office
addprint("IP_*.*.129.220,1,*.*.129.220,9100,,FALSE,Xerox ColorQube 9201 PS,\\*.*.200.14\path to inf,\\*.*.200.14\path to inf\x2WJ50P.inf,Central Office - Xerox ColorQube 9201 [SCAN],Central Office")

' ******* Food Services
addprint("IP_*.*.47.219,1,*.*.47.219,9100,,FALSE,Xerox WorkCentre 5135 PCL6,\\*.*.200.14\path to inf,\\*.*.200.14\path to inf\x2WPENX.inf,Food Services - Xerox WorkCentre 5135,Food Services")

' ******* Auto Tech


' ******* Butz
addprint("IP_*.*.95.219,1,*.*.95.219,9100,,FALSE,Xerox GPD PCL6 V2.1,\\*.*.200.14\path to inf,\\*.*.200.14\path to inf\x2UNIVX.inf,Butz - Curriculum - Xerox WorkCentre Pro 55 PCL6,Butz")

' ******* High School
addprint("IP_*.*.79.200,1,*.*.79.200,9100,,FALSE,HP LaserJet P2050 Series PCL6,\\*.*.200.14\path to inf,\\*.*.200.14\path to inf\hppcp613.inf,High School - Cate Mobile Lab - HP LaserJet P2055dn,High School")

' ******* Middle School
addprint("IP_*.*.63.219,1,*.*.63.219,9100,,FALSE,Xerox WorkCentre 5687 PCL6,\\*.*.200.14\path to inf,\\*.*.200.14\path to inf\x2WR75X.inf,Middle School - Xerox WorkCentre 5687 - A - [no scan],Middle School")

' ******* Intermediate
addprint("IP_*.*.47.220,1,*.*.47.220,9100,,FALSE,HP Color LaserJet 2600n,\\*.*.200.14\path to inf,\\*.*.200.14\path to inf\CLJ2600.INF,Intermediate - Lab Room 12 - Color LaserJet 2600,Intermediate")

' ******* Apache
addprint("IP_*.*.31.220,1,*.*.31.220,9100,,FALSE,HP LaserJet P2050 Series PCL6,\\*.*.200.14\path to inf,\\*.*.200.14\path to inf\hppcp613.inf,Apache - Mobile Lab Cart - HP LaserJet P2055dn,Apache")

' ******* Alamo
addprint("IP_*.*.111.221,1,*.*.111.221,9100,,FALSE,HP Color LaserJet 4600 PCL6,,,Alamo - Secretary - HP Color LaserJet 4600dn,Alamo")


Set objFSO = CreateObject("Scripting.FileSystemObject")
'Set CurrentFolder = objfso.GetFolder(".")

strComputer = "."
Set objWMIService = GetObject("winmgmts:" & _
"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

' ******** Generate the HTML to create the pulldown to select your branch location

sSelectHtm =sSelectHtm+ "</tr><td width=50%> <select id='branch'"&_
" onchange='Pickbranch' onblur='Pickbranch'>"
tmparray=split(strlocations,",")
For i = LBound(TmpArray) to UBound(TmpArray)
if tmparray(i)<>"" then sSelectHtm=sSelectHtm+"<option value="&chr(34)&tmparray(i)&chr(34)&">"&tmparray(i)
Next 'i
sSelectHtm=sSelectHtm+"</select>"
document.all.location.innerHTML=sSelectHtm


' *********** Here's the addprint function to add individual printer configs to the array.
Function addprint(strprinter)
tmparray=split(strprinter,",")
for z = 0 to ubound(tmparray)
Printers(x,z)=tmparray(z)
next ' z
erase tmparray
x=x+1
End Function

' ********* The user has choosen a branch - set the variable and call up the list of
' ********* printers for the selected location
Sub Pickbranch
strbranch=inputform.branch.value
'msgbox strbranch
call showprinters

end sub

' ********* Simply sets the variable for the selected printer
sub pickprinters
prnchoice=inputform.printers.value
end sub

' ********* Generate and display the list of printers for the selected location
Sub ShowPrinters
w=0

for y = 0 to x
if ucase(printers(y,10))=ucase(strbranch) then
prnlist(w,1)=strprnlist+printers(y,9)
prnlist(w,2)=cstr(y)
w=w+1
end if
next ' y

sSelectHtm="<hr><strong>Please choose the printer to install:</strong></tr><td width=50%> "
sSelectHtm =sSelectHtm+ "</tr><p><td width=50%><select id='printers'"&_
" onchange='pickprinters' onblur='pickprinters'>"
for y = 0 to (w-1)
sSelectHtm=sSelectHtm+"<option value="&prnlist(y,2)&">"&prnlist(y,1)
Next 'y
sSelectHtm=sSelectHtm+"</select>"
sSelectHtm=sSelectHtm+"</tr><tr> <input class=button type="&chr(34)&"button"&chr(34)&" onclick='SetupPrinter'"
sSelectHtm=sSelectHtm+"title="&chr(34)&"Click to Install Selected Printer"&chr(34)&" value="&chr(34)&"Install"&chr(34)&_
"id="&chr(34)&"install"&chr(34)&" name="&chr(34)&"install"&chr(34)&">"
if trim(ucase(strbranch))="SELECT YOUR LOCATION" then sSelectHtm=" "
document.all.listprinters.innerHTML=sSelectHtm
if sSelectHtm <> " " then inputform.install.focus
erase prnlist
End Sub


'************************ Quit Script if IE window is closed ************
Sub Window_OnClose()
on error resume next
erase folderlist
Self.close()
End Sub
'************************************************************************

Sub Window_Onload
'targetWidth = 300
'targetHeight = 200
'* resize parent window
'Self.ResizeTo 1,1
'self.MoveTo window.screen.availWidth - targetWidth, 0
'self.ResizeTo targetWidth,targetHeight
'* create dialog window
self.Focus()
intwdth=cint(document.body.clientwidth)
End Sub

Sub Changefocus
inputform.install.focus
end sub

' ********* Pull variables from the printer array
Sub SetupPrinter
call pickprinters

strportname= printers(prnchoice,0)
strportprot= printers(prnchoice,1)
strportaddy= printers(prnchoice,2)
strportnumb= printers(prnchoice,3)
strportqueue=printers(prnchoice,4)
strportsnmp= printers(prnchoice,5)
strdrvname= printers(prnchoice,6)
strdrvpath= printers(prnchoice,7)
strdrvinf= printers(prnchoice,8)
strprnid= printers(prnchoice,9)
strprnloc= printers(prnchoice,10)

' ********* Create the TCP/IP Port

Set objDriver = objWMIService.Get("Win32_PrinterDriver")

Set objNewPort = objWMIService.Get _
("Win32_TCPIPPrinterPort").SpawnInstance_

on error resume next

objNewPort.Name = strportname
objNewPort.Protocol = strportprot
objNewPort.HostAddress = strportaddy
objNewPort.PortNumber = strportnumb
if strportqueue<>"" then objNewPort.Queue = strportqueue
objNewPort.SNMPEnabled = strportsnmp
objNewPort.Put_
if err then strerror ="Error ("&err&") Occurred while creating TCP/IP Printer Port."&VBCRLF&_
"Portname: "&strportname & VBCRLF&"Protocol: "&strportprot&VBCRLF&"IP Address: "&strportaddy&VBCRLF&_
"Port Number: "&strportnumb&VBCRLF&" Port Queue: "&strportqueue&VBCRLF&"SNMP: "&strportsnmp&VBCRLF:msgbox strerror

' ********* Call printui.dll to install the driver and create the printer
strshell="rundll32 printui.dll,PrintUIEntry /if /b " & chr(34) & strprnid & chr(34) & " /f" & chr(34) & strdrvinf & chr(34) & " /r " & chr(34) & strportname & chr(34) &" /m " & chr(34) & strdrvname & chr(34) & " /z /q"
Set objShell = CreateObject("Wscript.Shell")
'Wscript.Echo objShell.CurrentDirectory

objShell.CurrentDirectory = "C:\Windows"
objShell.Run "cmd /c "&strshell, 0, True
Msgbox strprnid & " has been installed."

if err then strerror ="Error ("&err&") Occurred while installing the Printer Driver."&VBCRLF&_
"Driver Name: "&strdrvname&VBCRLF&"Driver Path: "&strdrvpath&VBCRLF&_
"Inf Path: "&"\"&strdrvinf &VBCRLF:msgbox strerror

End Sub

</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top