Printer Setup Batch File

bradzgoodz

Reputable
Dec 30, 2015
1
0
4,510
hiya

I have this code to install a home cannon printer to the laptop I run it on

CLS
@ECHO off

SET varIP=192.168.0.25
SET varDriver=
SET varDriverFolder=
SET varDriverFile=
SET varName=CanonOfflinePrinter
SET varLocation=

REM "Deleting TCP/IP port"
CSCRIPT /nologo %windir%\system32\Printing_Admin_Scripts\en-US\prnport.vbs -d -r IP_%varIP%

REM "Creating TCP/IP port"
CSCRIPT /nologo %windir%\system32\Printing_Admin_Scripts\en-US\prnport.vbs -a -r IP_%varIP% -o raw -n 9100 -h %varIP%

CLS
REM "Installation message"
@ECHO.
@ECHO The %varName% printer is currently being installed.
@ECHO.
@ECHO Please do not close this window.
@ECHO.
@ECHO Once the installation is complete this Setup window will exit.
@ECHO.


REM "Driver installation"
REM CSCRIPT /nologo %windir%\system32\\Printing_Admin_Scripts\en-US\prndrvr.vbs -a -m "%varDriver%" -h "%varDriverFolder%" -i "%varDriverFile%"


REM "Printer deletion"
@ECHO.
CSCRIPT /nologo %windir%\system32\\Printing_Admin_Scripts\en-US\prnmngr.vbs -d -p "%varName%"


REM "Printer installation"
@ECHO.
CSCRIPT /nologo %windir%\system32\\Printing_Admin_Scripts\en-US\prnmngr.vbs -a -p "%varName%" -m "%varDriver%" -r "IP_%varIP%"



REM "Location configuration"
@ECHO.
CSCRIPT /nologo %windir%\system32\\Printing_Admin_Scripts\en-US\prncnfg.vbs -t -p "%varName%" -l "%varLocation%"


REM "Making it Default printer"
REM CSCRIPT %windir%\system32\\Printing_Admin_Scripts\en-US\prnmngr.vbs -p "%varName%" -t
@echo Install Complete
timeout /t 10


but every time I run It I get a error like this

---------------------------------------------------------------------------------------

The CanonOfflinePrinter printer is currently being installed.

Please do not close this window.

Once the installation is complete this Setup window will exit.


Unable to delete printer CanonOfflinePrinter Error 0x80041002 Not found
Operation GetObject
Provider CIMWin32
Description
Win32 error code

Unable to add printer CanonOfflinePrinter Error 0x80041008 Invalid parameter
Operation PutInstance
Provider CIMWin32
Description
Win32 error code

Unable to get configuration for printer CanonOfflinePrinter Error 0x80041002 Not found
Operation GetObject
Provider CIMWin32
Description
Win32 error code
Install Complete

Waiting for 8^CTerminate batch job (Y/N)? inue ...


--------------------------------------------------------------------------------------------------------------------

every forum I look at it says about using a .inf file to install the drivers but the printer automatically installs them

many thanks
 

TRENDING THREADS