Many times we have the perennial problem in Active Directory environments that occasionally a user session on a machine that is not his usual, this causes without designated network printers to install printers, you can use this script:
one file instalar.bat that installs the printer, use the microsoft script prnmngr.vbs , first check that the printer is not connected in this case\\servidor\impressorared, if there is then installed on another call at the same script
Finally use the scriptdefprinter.vbs, establishing it as the default

 REM ***** Check and Install Copier*****
cscript prnmngr.vbs -l | find "Printer name \\servidor\impressorared"
IF ERRORLEVEL 1 ( cscript prnmngr.vbs -ac -p "\\servidor\impressorared"
echo "\\iocor\fax installed"
)
cscript defprinter.vbs \\servidor\impressorared

the script defprinter.vbs:

Option Explicit
dim objArgs
Set objArgs = WScript.Arguments
Dim objPrinter
Set objPrinter = CreateObject("WScript.Network")
objPrinter.SetDefaultPrinter objArgs(0)
' End of example VBScript
Facebooktwittergoogle_plusredditpinterestlinkedinmail