Hello,
This is my first time posting so please let me know if more information is required.
This is a script to add printers that is ran from the local desktop. The issue is that the naming scheme of the printers changed.
The original script only required four digits (ID) and the script would run because all the names start with the same information. If the printer was not found on the server it would exit the script, otherwise it install the printer and ask if the printer is default.
The current script requires type, model and ID before it has enough information to run.
Original name Ex. PRINTPRNAME1234 (this requires the ID)
PRINT= item, PR= Printer type, NAME= name of printer, 1234=Printer ID
Now the name has more options.
Type="MC=Multi-Function, PL=Plotter, PR=Printer", Model="DE, HP, KM, LX"
New name Ex. PRINTMCHP123456 (this requires type, model and ID)
PRINT= item, MC= type, HP= model, 123456= ID
The below script works, but it requires the person to manually add the information to create the name.
Is there any way it can automatically search the server using the ID and if it finds the ID automatically fill in the type and model?
Thanks.
This is my first time posting so please let me know if more information is required.
This is a script to add printers that is ran from the local desktop. The issue is that the naming scheme of the printers changed.
The original script only required four digits (ID) and the script would run because all the names start with the same information. If the printer was not found on the server it would exit the script, otherwise it install the printer and ask if the printer is default.
The current script requires type, model and ID before it has enough information to run.
Original name Ex. PRINTPRNAME1234 (this requires the ID)
PRINT= item, PR= Printer type, NAME= name of printer, 1234=Printer ID
Now the name has more options.
Type="MC=Multi-Function, PL=Plotter, PR=Printer", Model="DE, HP, KM, LX"
New name Ex. PRINTMCHP123456 (this requires type, model and ID)
PRINT= item, MC= type, HP= model, 123456= ID
The below script works, but it requires the person to manually add the information to create the name.
Is there any way it can automatically search the server using the ID and if it finds the ID automatically fill in the type and model?
Thanks.
Code:
On Error Resume Next
Dim MSG, MSG1, MSG2, MSG3, MSG4
Dim Style, Style2, Style4
Dim Title, Title1, Title2, Title4
Dim Response, Response1, Response2, Response3, Response4
Dim AddPrinter, SetDefault, PrinterName
MSG = "Install a Network Printer?"
Style = vbOKCancel + vbQuestion
Title = "Network Printer Install"
MSG1 = "MC=Multi-Function, PL=Plotter, PR=Printer"
MSG2 = "Enter Model, DE, HP, KM, LX"
MSG3 = "Enter 6 digit ECN"
Style4 = "Default Printer?"
Title4 = "Y"
AddPrinter = False
SetDefault = False
Response = MsgBox(MSG, Style, Title)
Set WshNetwork = CreateObject("WScript.Network")
If Response = 1 Then
Response1 = InputBox(MSG1, Style)
Response1 = UCase(Response1)
if Response1 <> "" then
Response2 = InputBox(MSG2, Style)
Response2 = UCase(Response2)
if Response2 <> "" then
Response3 = InputBox(MSG3, Style)
if Response3 <> "" then
PrinterName = "\\PRINTSERVER01\PRINT" & Response1 & Response2 & Response3
AddPrinter = True
MSG4 = "Make printer: " & PrinterName & " the Default Printer (OK=Yes/Cancel=No)"
Response4 = InputBox(MSG4, Style4, Title4)
If Response4 = "Y" Then
SetDefault = True
Else
SetDefault = False
End If
If AddPrinter = True Then
WshNetwork.AddWindowsPrinterConnection PrinterName
If SetDefault = True Then
WshNetwork.SetDefaultPrinter PrinterName
End If
End if
End if
End If
Else
AddPrinter = False
MsgBox "Operation Aborted!"
End If
Else
AddPrinter = False
SetDefault = False
MsgBox "Operation Aborted!"
End If