We help IT Professionals succeed at work.

Logon script to remove all network printer and install new printer

Medium Priority
Last Modified: 2013-11-30
What is the logon script to remove all the network printers and to remap new printers. I have windows 2003 server with 2 network printers installed and shared for 100 windows XP clients. I need to change the server.
Watch Question

Shane Russell2nd Line Desktop Support

Just as an FYI - am putting one together and will post back as soon as I get a working example.
2nd Line Desktop Support
here is an example script that I did quite some time ago

If you need help with it or want to understand it a bit more then post back but basically I have delcared room names at the start that are

IT2 etc

and each of those room names has the share name assigned to it so if you have a hp printer that is in room 1 then I have assigned the share name to the room name variable

also you will need to change the server name in the add printer function when you call it so that it points to your server via its netbios name or ip address ie

currently it is

    Case "ES"
      call AddPrinter("\\cse2k01\",EdSupport)

where as you will need to alter it so that it is

    Case "ES"
      call AddPrinter("\\your_server\", variable)

anyway HTH

Post back if the computer name part does not work for you and let me know what your client computer names are like and we can edit the code below.

Dim SleepTime
'upper school printers
Dim IT1
Dim IT2
Dim IT3
Dim IT4
Dim IT6
Dim TechU
Dim LibrarySixth
'lower school printers
Dim ICT5
Dim ICT6
Dim ICT8
Dim TechL
Dim EdSupport
Dim AName
IT1 = "kyoceraM"
Set WSHNetwork = CreateObject("WScript.Network")
strComputer = WSHNetwork.ComputerName
AName = Left(strComputer,Len(strComputer)-4)
Select Case AName
    Case "IT1"
	call AddPrinter("\\cse2k01\",IT1)
	MsgBox "Added Printer : " & IT1
    Case "IT2"
	call AddPrinter("\\cse2k01\",IT2)
	MsgBox "Added Printer : " & IT2
    Case "IT3"
	call AddPrinter("\\cse2k01\",IT3)
	MsgBox "Added Printer : " & IT3
    Case "IT4"
	call AddPrinter("\\cse2k01\",IT4)
	MsgBox "Added Printer : " & IT4
    Case "DT"
	call AddPrinter("\\cse2k01\",TechU)
	MsgBox "Added Printer : " & TechU
    Case "IT6"
	call AddPrinter("\\cse2k01\",IT6)
	MsgBox "Added Printer : " & IT6
    Case "LibrarySixth"
	call AddPrinter("\\cse2k01\",LibrarySixth)
	MsgBox "Added Printer : " & LibrarySixth
    Case "ICT5"
	call AddPrinter("\\cse2k01\",ICT5)
	MsgBox "Added Printer : " & ICT5
    Case "ICT6"
	call AddPrinter("\\cse2k01\",ICT6)
	MsgBox "Added Printer : " & ICT6
    Case "ICT8"
	call AddPrinter("\\cse2k01\",ICT8)
	MsgBox "Added Printer : " & ICT8
    Case "DTLS"
	call AddPrinter("\\cse2k01\",TechL)
	MsgBox "Added Printer : " & TechL
    Case "ES"
	call AddPrinter("\\cse2k01\",EdSupport)
	MsgBox "Added Printer : " & EdSupport
End Select
Public Function AddPrinter(ByRef Server,ByRef strPrinter)
Set WshNetwork = CreateObject("WScript.Network")
rem ** This will delete existing printers **
On Error Resume Next
Set oPrinters = WshNetwork.EnumPrinterConnections
        For i = 1 to oPrinters.Count - 1 Step 2
               WshNetwork.RemovePrinterConnection oPrinters.Item(i)
rem ** Setup new printer connection **
WshNetwork.AddWindowsPrinterConnection Server & strPrinter
rem ** Pause Script **
WScript.Sleep SleepTime*1000
rem ** Setup default printer **
WshNetwork.SetDefaultPrinter Server & strPrinter
End Function

Open in new window

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Shane Russell2nd Line Desktop Support

why the B grade - fully working script that sets it as default , removes all printers etc as requested ?
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.