Currently I use the following script to map printers:
How can I modify it so that the script will look for the shared printers on the server and then map it if it is shared so that I don't have to keep adding printer names to the array. Thanks.
Dim i,j,PrinterPath,Printer,wshnetwork,cPrinters,bFound,arrArray
arrArray=array("ACCH01","ACCH02","ACCH03","BBCH01","CHCH01","ERBHRCH01", "ERCDCCH01","ERCPCCH01", _
"EREMRCH01","ERFSTCH01","EROBGCH01","ERPERCH01","ERRSSCH01","ERTRMCH01","FDCH01", _
"ICCH01","LOCH01","MBCH01","NS1NOCH01","NS1SECH01","NS1SOCH01","NS2SOCH01","NS2WECH01", _
"NS3SOCH01","NS3WECH01","NS4NOCH01","NS4SOCH01","NS5NOCH01","NS5SOCH01","NSBCUCH01","NSCATHCH01", _
"NSCCUCH01","NSCVCUCH01","NSFBCCCH01","NSHROBCH01","NSIMCCH01","NSLDCH01","NSMICU1CH01","NSMICU2CH01", _
"NSNICU1CH01","NSNICU2CH01","NSNSCUCH01","NSONCCH01","NSPACU1CH01","NSPACU2CH01","NSPEDCH01","NSPICUCH01", _
"NSPOVFCH01","NSRRHCH01","NSSICUCH01","NSTICUCH01","NSTPACUCH01","QACH01","QBCH01","QCCH01","QECH01","QHCH01", _
"QMCH01","QNCH01","QPCH01","QRCH01","QSCH01","QUCH01","QVCH01","TRCH01","ONCH01","LOCH02","PHCH01", "MGRCH01", "NSAMBSURCH01", _
"NSTRNSRVCH01", "NSWELLCTRCH01", "NSUWCCH01", "NSPOPCCH01", "NSOPCCH01", "billcodch01", "nsmedrecch01", "nscthlabch01", "nsperimpch01")
set wshnetwork=createobject("wscript.network")
set cPrinters=wshnetwork.EnumPrinterConnections
bFound=false
For j= LBound(arrArray) To UBound(arrArray)
Printer=arrArray(j)
PrinterPath = "\\Pathsrv\" & Printer
for i=0 to cPrinters.count-1 step 2
if strComp(cstr(cPrinters.Item(i+1)), cstr(PrinterPath), 1)=0 then
bFound=true
exit for
end if
next
if Not bFound then
wshnetwork.AddWindowsPrinterConnection PrinterPath
end if
bFound=false
Next
set cPrinters=nothing
set wshnetwork=nothing
How can I modify it so that the script will look for the shared printers on the server and then map it if it is shared so that I don't have to keep adding printer names to the array. Thanks.
Dim i,j,PrinterPath,Printer,wshnetwork,cPrinters,bFound,arrArray
arrArray=array("ACCH01","ACCH02","ACCH03","BBCH01","CHCH01","ERBHRCH01", "ERCDCCH01","ERCPCCH01", _
"EREMRCH01","ERFSTCH01","EROBGCH01","ERPERCH01","ERRSSCH01","ERTRMCH01","FDCH01", _
"ICCH01","LOCH01","MBCH01","NS1NOCH01","NS1SECH01","NS1SOCH01","NS2SOCH01","NS2WECH01", _
"NS3SOCH01","NS3WECH01","NS4NOCH01","NS4SOCH01","NS5NOCH01","NS5SOCH01","NSBCUCH01","NSCATHCH01", _
"NSCCUCH01","NSCVCUCH01","NSFBCCCH01","NSHROBCH01","NSIMCCH01","NSLDCH01","NSMICU1CH01","NSMICU2CH01", _
"NSNICU1CH01","NSNICU2CH01","NSNSCUCH01","NSONCCH01","NSPACU1CH01","NSPACU2CH01","NSPEDCH01","NSPICUCH01", _
"NSPOVFCH01","NSRRHCH01","NSSICUCH01","NSTICUCH01","NSTPACUCH01","QACH01","QBCH01","QCCH01","QECH01","QHCH01", _
"QMCH01","QNCH01","QPCH01","QRCH01","QSCH01","QUCH01","QVCH01","TRCH01","ONCH01","LOCH02","PHCH01", "MGRCH01", "NSAMBSURCH01", _
"NSTRNSRVCH01", "NSWELLCTRCH01", "NSUWCCH01", "NSPOPCCH01", "NSOPCCH01", "billcodch01", "nsmedrecch01", "nscthlabch01", "nsperimpch01")
set wshnetwork=createobject("wscript.network")
set cPrinters=wshnetwork.EnumPrinterConnections
bFound=false
For j= LBound(arrArray) To UBound(arrArray)
Printer=arrArray(j)
PrinterPath = "\\Pathsrv\" & Printer
for i=0 to cPrinters.count-1 step 2
if strComp(cstr(cPrinters.Item(i+1)), cstr(PrinterPath), 1)=0 then
bFound=true
exit for
end if
next
if Not bFound then
wshnetwork.AddWindowsPrinterConnection PrinterPath
end if
bFound=false
Next
set cPrinters=nothing
set wshnetwork=nothing