Perhaps you know the problem, you need to install new Printers for all your Users. But this can be really a pain, so here is a little .VBS script. This Script look in a text file containing the UNC path of the Printer, for example:
\printserver1.domain.chprintername1
\printserver1.domain.chprintername2
\printserver2.domain.chprintername3
So you start the Script, it will install all Printers in the text file — end of story. There is also a Uninstall Script included.
download the .VBS Scripts here
The install Script:
=================================================
Option Explicit
Dim WSHShell, fso, FileIn, FileOut
Dim Datei, Text, Txt, i, arrSort, arrTest(), oArgs
Dim objNetwork, strUNCPrinter
Set WSHShell = WScript.CreateObject(“WScript.Shell”)
Set fso = WScript.CreateObject(“Scripting.FileSystemObject”)
’ prüfen ob Datei existiert
’ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Datei = “Printer.txt”
If not fso.FileExists( Datei ) then
MsgBox UCase( Datei ) & ” existiert nicht!” & vbCRLF & vbCRLF & ” … das ist das Ende.”, , WScript.ScriptName
WScript.Quit
End If
’ alle Zeilen lesen und an Array übergeben
’ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Set FileIn = FSO.OpenTextFile(Datei, 1, true) ’ Datei zum Lesen öffnen
i=0
Do While Not (FileIn.atEndOfStream) ’ wenn Datei nicht zu ende ist, weiter lesen
ReDim Preserve Zeile(i)
Zeile(i) = FileIn.Readline
i = i + 1
Loop
If i < 1 Then
ReDim Preserve Zeile(i)
Zeile(i) = “Leerdatei”
End If
FileIn.Close
Set FileIn = nothing
’ Drucker installieren
’ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
for i = 0 to ubound( Zeile )
strUNCPrinter=Zeile(i)
Set objNetwork = CreateObject(“WScript.Network”)
objNetwork.AddWindowsPrinterConnection strUNCPrinter
next
=================================================
and the uninstall Script:
=================================================
Option Explicit
Dim WSHShell, fso, FileIn, FileOut
Dim Datei, Text, Txt, i, arrSort, arrTest(), oArgs
Dim objNetwork, strUNCPrinter, bForce, bUpdateProfile
Set WSHShell = WScript.CreateObject(“WScript.Shell”)
Set fso = WScript.CreateObject(“Scripting.FileSystemObject”)
’ prüfen ob Datei existiert
’ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Datei = “Printer.txt”
If not fso.FileExists( Datei ) then
MsgBox UCase( Datei ) & ” existiert nicht!” & vbCRLF & vbCRLF & ” … das ist das Ende.”, , WScript.ScriptName
WScript.Quit
End If
’ alle Zeilen lesen und an Array übergeben
’ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Set FileIn = FSO.OpenTextFile(Datei, 1, true) ’ Datei zum Lesen öffnen
i=0
Do While Not (FileIn.atEndOfStream) ’ wenn Datei nicht zu ende ist, weiter lesen
ReDim Preserve Zeile(i)
Zeile(i) = FileIn.Readline
i = i + 1
Loop
If i < 1 Then
ReDim Preserve Zeile(i)
Zeile(i) = “Leerdatei”
End If
FileIn.Close
Set FileIn = nothing
’ Drucker installieren
’ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bForce = “True“
bUpdateProfile = “False“
on Error Resume Next ‘wenn Drucker nicht installiert ist
for i = 0 to ubound( Zeile )
strUNCPrinter=Zeile(i)
Set objNetwork = CreateObject(“WScript.Network”)
objNetwork.RemovePrinterConnection strUNCPrinter, bForce, bUpdateProfile
next
=================================================
