Posteado por: El Conde | 25 febrero 2007

Ejemplo en VBS para agregar una printer al SO

Example 2 – Printer Script with AddWindowsPrinterConnection

This script has the same core as the first example but with a few extra coding niceties. As you get to know my VBScript style, so you will see my familiar heading section, liberal use of variables, and a WScript.Echo message box to confirm what has happened.


‘ PrintersLong.vbs – Windows Logon Script.
‘ VBScript – Connect a network printer with AddWindowsPrinterConnection
‘ Author Guy Thomas
‘ Version 2.2 – April 24th 2005
‘ ——————————————————————————‘
Option Explicit
Dim objNetwork, strUNCPrinter
strUNCPrinter = “\\zara\HP LaserJet”
Set objNetwork = CreateObject(“WScript.Network”)
objNetwork.AddWindowsPrinterConnection strUNCPrinter
WScript.Echo “Check the Printers folder for : ” & strUNCPrinter


‘ End of Guy’s Windows printer script.

VBS Learning Points

Note 1:  Option Explicit forces us to declare variables before we use them in the VBScript.  The idea is to reduce spelling mistakes.

Note 2:  One reason that I like to employ variables is to make it easier to troubleshoot in general and display messages with WScript.Echo in particular.

Note 3: To help with the line numbers, and to color code your commands get OnScript (free download).



  1. ford detroit


Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de

Estás comentando usando tu cuenta de Cerrar sesión /  Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión /  Cambiar )


Conectando a %s


A %d blogueros les gusta esto: