Script Builder – Remove Existing Printers

ScriptBuilder can automatically add network printers based on the computer name, username or group membership. If you add printers based on the computer name, you might find that users accumulate a large collection of printers as they move from PC to PC. This problem will occur for users with roaming user profiles, as the printer connections are stored in the users profile. To remove any existing network printers, follow the procedure below:

  • Open ScriptBuilder
  • Click the “Code editor” icon
Script Builder Toolbar
  • Expand the Global (All Scripts) section.
  • Select “Footer”
  • Paste the following code into the text box to the right:

Example Below: 

  • Click the “Header” section under Global (All Scripts)
  • Click “Yes” to save changes.
  • Enter the following text into the text box on the right: RemoveNetworkPrinters
Script Builder - Global Header
  • Click “Exit” and click “Yes” to save changes.

The next time the script is built and run, the code added in the procedure above will ensure that any existing network printer connections are removed before the script is run. If you open the script file produced by script builder you will notice that the “RemoveNetworkPrinters” function has been added to the end of the script. You will also notice that this function is called at the beginning of the script.

Note: If a particular user wants to maintain a connection to a shared printer, you will need to add the printer to the script under Users or Groups section. If a user connects to a printer manually, that printer connection will be removed the next time the script is run. Also note that the “Code editor” section of ScriptBuilder has so far been undocumented. An incorrect modification can stop the script from working entirely, so please test the script after making any modifications. Upgrades to ScriptBuilder in the future have the potential to break any custom functionality added using code editor.