Join the Community! Creating your account only takes a few minutes.

I have two scripts that I need to combin into one - can someone please assist me in doing this? I would like to create one script file that removes all network printers and then adds all the printers. We change printers like there is no tomorrow - always adding and deleting. Unless someone has a better way of doing this?

Here's the script I use (follow the link). Very simple and works like a champ. Uncomment the remove connections and those printers will be deleted. This is helpful when you need the system to update the printer driver to a new one loaded on the server. The last line sets the default printer.

1st Post

This below seems like a simple script can you help me understand how I might reconfigure it to install these network printers as a local port? I have learned when doing a migration in the past that adding network printers as a local port allows me to add it one time for all users on the system now and in the future.

Spiceuser's script worked like a charm it did everything that i wanted it to do, except one thing one of the parameters of the command is incorrect.
'objNetwork.RemoveWindowsPrinterConnection "\\server\2nd_printer_to_remove"

1st Post

1st Post

I too was looking for a script to do exactly this and P. J. Carmen's script worked perfectly. I am wondering if the script can be edited to remember which of the removed printers was set as default and then reset this printer as default? We will be removing and adding the same printers to refresh the settings to default each day but would like it to be as seamless as possible for the user.

For Each oThing in colPrinters
If oThing.Default Then
If isNull (oThing.Servername) Then
sDefPrinter = oThing.PortName
ElseIf oThing.Servername <> "" then
sDefPrinter = oThing.ServerName & "\" & oThing.ShareName
End If
End If
Next

For i=0 to Ubound(arrValueNames)
if Left(arrValueNames(i),2) = "\\" and not Left(arrValueNames(i),2) ="\\PBC_NDS" then
refRegistry.DeleteValue HKEY_CURRENT_USER, strKey, arrValueNames(i)
'msgbox "Delete: " & strKey & arrValueNames(i)
End If
Next

End Sub

'*****************************************************************
'*****************************************************************
'*****************************************************************
' Add a associated printers if the computer is a member of the group.
' Set specified printer as default

If FSO.FileExists(FileName) Then
Dim file
Set file = FSO.GetFile(FileName)
' Open the file
Dim TextStream
Set TextStream = file.OpenAsTextStream(ForReading,TristateUseDefault)
' Read the file line by line
Dim Line
Dim Group
Dim Printer
Dim Default
Do While Not TextStream.AtEndOfStream
Line = TextStream.readline
if left(Line,1) = ":" then
Group = Replace(Line,":","")

elseif left(Line,2) = "\\" then
Printer = Line

If IsMember(objComputer, Trim(Group)) Then
objNetwork.AddWindowsPrinterConnection Trim(Printer)
End If
' elseif Lcase(left(Line,3)) = "set" then
' Default = Replace(Line,"SetDefault,","")
'
' If IsMember(objComputer, Trim(Group)) Then
' objNetwork.SetDefaultPrinter Trim(Default)
' End If

End If

Loop

Set TextStream = Nothing

Else
' MsgBox "Cannot find Parameters File '" & FileName & "'"

End If

Set FSO = Nothing
'*****************************************************************
'*****************************************************************
'*****************************************************************
'Check Membership of "Default to Local Printer" Group
'If membership is true, set local printer to default.

If IsMember(objComputer, "Default to Local Printer") Then
objNetwork.SetDefaultPrinter "LPT1:"
objNetwork.SetDefaultPrinter "USB001"
End If

1st Post

I use this script to remove all printers. First I check the default printer for saving. Then removing all printers.

Then I connect the default printer again (in my scenrio on another printer server). Within another KIX-script I add all other printers. Works like a charm when you nedd to change printerserver and retain default printer.

Spiceuser's script worked like a charm it did everything that i wanted it to do, except one thing one of the parameters of the command is incorrect.
'objNetwork.RemoveWindowsPrinterConnection "\\server\2nd_printer_to_remove"

1st Post

Can help me how to adding network printers at user logon Script. How to create scipt ..Jordan Roth wrote:

I have two scripts that I need to combin into one - can someone please assist me in doing this? I would like to create one script file that removes all network printers and then adds all the printers. We change printers like there is no tomorrow - always adding and deleting. Unless someone has a better wayJordan Roth wrote:

I have two scripts that I need to combin into one - can someone please assist me in doing this? I would like to create one script file that removes all network printers and then adds all the printers. We change printers like there is no tomorrow - always adding and deleting. Unless someone has a better way of doing this?

Jordan Roth wrote:

I have two scripts that I need to combin into one - can someone please assist me in doing this? I would like to create one script file that removes all network printers and then adds all the printers. We change printers like there is no tomorrow - always adding and deleting. Unless someone has a better way of doing this?

Mark D. MacLachlan uses the following to remove /just/ network printers in his script:

'Remove ALL old printers
'Enumerate all printers first, after that you can select the printers you want by performing some string checks
Set WSHPrinters = WSHNetwork.EnumPrinterConnections
For LOOP_COUNTER = 0 To WSHPrinters.Count - 1 Step 2
'To remove only networked printers use this If Statement
If Left(WSHPrinters.Item(LOOP_COUNTER 1),2) = "\\" Then
WSHNetwork.RemovePrinterConnection WSHPrinters.Item(LOOP_COUNTER 1),True,True
End If
'To remove all printers incuding LOCAL printers use this statement and comment out the If Statement above
'WSHNetwork.RemovePrinterConnection WSHPrinters.Item(LOOP_COUNTER 1),True,True
Next

1st Post

Phil Adler wrote:

Ian9176 wrote:

Spiceuser's script worked like a charm it did everything that i wanted it to do, except one thing one of the parameters of the command is incorrect.
'objNetwork.RemoveWindowsPrinterConnection "\\server\2nd_printer_to_remove"