Link to home
Start Free TrialLog in
Avatar of jmls
jmlsFlag for United States of America

asked on

adding an LPR port, then adding a printer via command line

Im in the process of creating a .bat file that
1. Creates a LPR port
2. installs a printer and driver

my script thus far is this

REM       Win7 sys32 Installer
REM      1-26-10 (j.f.)
REM       ONCE THIS INSTALLER HAS STARTED DO NOT STOP IT
REM        **VISTA USERS PLEASE NOTE**
REM       this installer may take serveral minutes to complete, if you have any questions please contact the helpdesk
@echo off
REGEDIT32 /s win.reg
net stop spooler
net start spooler

Ocsetup.exe  Printing-Foundation-LPRPortMonitor /passive /norestart
Ocsetup.exe  Printing-Foundation-LPDPrintService /passive /norestart


rundll32.exe printui.dll,PrintUIEntry /if /b "JMLS Printer" /m "Canon iR-ADV C5045/5051 PS3" /h"x86 /v "windows 7" /f "CNS30U.INF" /q /r "10.128.0.16"
CLS
EXIT


With a .reg file that looks like this:


[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\LPR Port\Ports\10.128.0.16:studenthold]
"Server Name"="10.128.0.16"
"Printer Name"="studenthold"
"OldSunCompatibility"=dword:00000000
"HpUxCompatibility"=dword:00000000
"EnableBannerPage"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\LPR Port\Ports\10.128.0.16:studenthold\Timeouts]
"CommandTimeout"=dword:00000078
"DataTimeout"=dword:0000012c

The issue I am having is that the registry keys for some wierd reason wont load, and I keep on recieving a invalid argument error.  Im almost positive my syntax is correct but Im starting to pul my hair out over this.  

BTW this is a Win 7 x86 installer.  
Avatar of Adam Leinss
Adam Leinss
Flag of United States of America image

Sounds like an UAC issue.
According to http://msdn.microsoft.com/en-us/library/aa826699(VS.85).aspx, you have three ways to run a script in elevated mode:
  1. Open a Command Prompt window by right-clicking Command Prompt in the Start menu and then clicking Run as administrator.
  2. Schedule the script to run elevated using Task Scheduler.
  3. Run the script using the built-in Administrator account.
     
Avatar of jmls

ASKER

Ive tried to run the script as administrator, no luck
Won't load as they aren't created in the registry at all?
I just tried your REG file and it loaded correctly into the registry.  I did this from a PC running Windows 7 Enterprise x86.
The reg file should have this at the beginning of the file:

Windows Registry Editor Version 5.00
Avatar of jmls

ASKER

Yeah the reg file loads correctly when you click it however it will not load from the script.  I have all the files that are mentioned in this batch script in the same directory as the batch script if that helps.  Perhaps adding ~dp0 in the begining
Avatar of jmls

ASKER

hmm made some progress it isnt erroring out anymore but the registry keys still are not loading nor is my printer
I see you have regedit32 /s win.reg.  I tried this on my Windows 7 machine and it won't work, but regedit does.  I believe REGEDT32.EXE was phased out and just combined into REGEDIT after Windows 2000.
Avatar of jmls

ASKER

Yeah I fixed that aswell.  the new script looks like this:

REM       Win7 sys32 Installer
REM      1-26-10 (j.f.)
REM       ONCE THIS INSTALLER HAS STARTED DO NOT STOP IT
REM        **VISTA USERS PLEASE NOTE**
REM       this installer may take serveral minutes to complete, if you have any questions please contact the helpdesk
REM      in room 217 or at 312-427-2737 x 550
@echo off
REGEDIT /s win7.reg
net stop spooler
net start spooler

Ocsetup.exe  Printing-Foundation-LPRPortMonitor /passive /norestart
Ocsetup.exe  Printing-Foundation-LPDPrintService /passive /norestart


rundll32.exe printui.dll,PrintUIEntry /if /b "JMLS Printer" /m "Canon iR-ADV C5045/5051 PS3" /h "Intel" /v "Windows 7" /f "CNS30U.INF" /q /r "10.128.0.16:studenthold"
CLS
EXIT
Avatar of jmls

ASKER

well I figured out that the .reg file will not load because it
Your message got cut off.
Avatar of jmls

ASKER

dont know how the above got posted,  what I meant to say is I fixed the error of the registry not loading,  it had to do with UAC on my Virtual Machine I was testing it on.  The proper ports load however the drivers and printer are still not showing up
Are the drivers and CNS30U.INF in the same directory you are running the script from?
Avatar of jmls

ASKER

yes the contents of the INF file is as follows:

; Canon PS3 printer INF for Microsoft Windows (x86)
; Copyright CANON INC. 2009 All Rights Reserved
; CNS30U.INF (CD-ROM Release)

[Version]
Signature="$Windows NT$"
Provider=%CANON%
ClassGUID={4D36E979-E325-11CE-BFC1-08002BE10318}
Class=Printer
DriverVer=09/18/2009,20.11.0.0
CatalogFile=CNS30U.CAT

[Manufacturer]
"Canon" = Canon,NTx86.5.1,NTx86.6.0

;Windows2000
[Canon]
"Canon iPR1110/1125/1135 PS3"     = IPR1135, USBPRINT\CanoniPR1110/1125/11A0A3
"Canon iR-ADV C5030/5035 PS3"     = ADVC5035, USBPRINT\CanoniR-ADV_C5030/50C693
"Canon iR-ADV C5045/5051 PS3"     = ADVC5051, USBPRINT\CanoniR-ADV_C5045/508750
"Canon iR-ADV C7055/7065 PS3"     = ADVC7065, USBPRINT\CanoniR-ADV_C7055/70F875
"Canon iR-ADV C9065/9075 PS3"     = ADVC9065, USBPRINT\CanoniR-ADV_C9065/90065E

;WindowsXP
[Canon.NTx86.5.1]
"Canon iPR1110/1125/1135 PS3"     = IPR1135, USBPRINT\CanoniPR1110/1125/11A0A3
"Canon iR-ADV C5030/5035 PS3"     = ADVC5035, USBPRINT\CanoniR-ADV_C5030/50C693
"Canon iR-ADV C5045/5051 PS3"     = ADVC5051, USBPRINT\CanoniR-ADV_C5045/508750
"Canon iR-ADV C7055/7065 PS3"     = ADVC7065, USBPRINT\CanoniR-ADV_C7055/70F875
"Canon iR-ADV C9065/9075 PS3"     = ADVC9065, USBPRINT\CanoniR-ADV_C9065/90065E

;WindowsVista
[Canon.NTx86.6.0]
"Canon iPR1110/1125/1135 PS3"     = IPR1135, USBPRINT\CanoniPR1110/1125/11A0A3
"Canon iPR1110/1125/1135 PS3"     = IPR1135, WSDPRINT\CanoniPR1110/1125/11A0A3
"Canon iPR1110/1125/1135 PS3"     = IPR1135, CanoniPR1110/1125/11A0A3
"Canon iR-ADV C5030/5035 PS3"     = ADVC5035, USBPRINT\CanoniR-ADV_C5030/50C693
"Canon iR-ADV C5030/5035 PS3"     = ADVC5035, WSDPRINT\CanoniR-ADV_C5030/50C693
"Canon iR-ADV C5030/5035 PS3"     = ADVC5035, CanoniR-ADV_C5030/50C693
"Canon iR-ADV C5045/5051 PS3"     = ADVC5051, USBPRINT\CanoniR-ADV_C5045/508750
"Canon iR-ADV C5045/5051 PS3"     = ADVC5051, WSDPRINT\CanoniR-ADV_C5045/508750
"Canon iR-ADV C5045/5051 PS3"     = ADVC5051, CanoniR-ADV_C5045/508750
"Canon iR-ADV C7055/7065 PS3"     = ADVC7065, USBPRINT\CanoniR-ADV_C7055/70F875
"Canon iR-ADV C7055/7065 PS3"     = ADVC7065, WSDPRINT\CanoniR-ADV_C7055/70F875
"Canon iR-ADV C7055/7065 PS3"     = ADVC7065, CanoniR-ADV_C7055/70F875
"Canon iR-ADV C9065/9075 PS3"     = ADVC9065, USBPRINT\CanoniR-ADV_C9065/90065E
"Canon iR-ADV C9065/9075 PS3"     = ADVC9065, WSDPRINT\CanoniR-ADV_C9065/90065E
"Canon iR-ADV C9065/9075 PS3"     = ADVC9065, CanoniR-ADV_C9065/90065E

[OEM URLS]
%CANON% = "http://www.canon.com/support"

[IPR1135]
CopyFiles=IPR1135_FILES,PS_FILES,NETSPOT_CPCA,DRVCOPY,NETSPOT_COMMON
DataFile=CNPR1110U1.PPD
DataSection=IPR1135_DATA
LanguageMonitor=%NS_LMON_CPCA%

[ADVC5051]
CopyFiles=ADVC5051_FILES,PS_FILES,NETSPOT_CPCA,DRVCOPY,NETSPOT_COMMON
DataFile=CNADVC5045U1.PPD
DataSection=ADVC5051_DATA
LanguageMonitor=%NS_LMON_CPCA%

[ADVC5035]
CopyFiles=ADVC5035_FILES,PS_FILES,NETSPOT_CPCA,DRVCOPY,NETSPOT_COMMON
DataFile=CNADVC5030U1.PPD
DataSection=ADVC5035_DATA
LanguageMonitor=%NS_LMON_CPCA%

[ADVC7065]
CopyFiles=ADVC7065_FILES,PS_FILES,NETSPOT_CPCA,DRVCOPY,NETSPOT_COMMON,COLORGEAR_KYNS
DataFile=CNADVC7055U1.PPD
DataSection=ADVC7065_DATA
LanguageMonitor=%NS_LMON_CPCA%

[ADVC9065]
CopyFiles=ADVC9065_FILES,PS_FILES,NETSPOT_CPCA,DRVCOPY,NETSPOT_COMMON,COLORGEAR_KYNS
DataFile=CNADVC9065U1.PPD
DataSection=ADVC9065_DATA
LanguageMonitor=%NS_LMON_CPCA%

[IPR1135_DATA]
DriverFile=CNS30M_DFCF3.DLL
ConfigFile=CNS30MUI_DFCF3.DLL
HelpFile=CNS31U_DFCF3.chm

[ADVC5051_DATA]
DriverFile=CNS30M_D7193.DLL
ConfigFile=CNS30MUI_D7193.DLL
HelpFile=CNS31U_D7193.chm

[ADVC5035_DATA]
DriverFile=CNS30M_DB368.DLL
ConfigFile=CNS30MUI_DB368.DLL
HelpFile=CNS31U_DB368.chm

[ADVC7065_DATA]
DriverFile=CNS30M_DE5E0.DLL
ConfigFile=CNS30MUI_DE5E0.DLL
HelpFile=CNS31U_DE5E0.chm

[ADVC9065_DATA]
DriverFile=CNS30M_D7279.DLL
ConfigFile=CNS30MUI_D7279.DLL
HelpFile=CNS31U_D7279.chm

[IPR1135_FILES]
CNS30M_DFCF3.DLL,CNS30M.DLL
CNS30MUI_DFCF3.DLL,CNS30MUI.DLL
CNS30409_DFCF3.DLL,CNS30409.DLL
IP1135SU.XPD
IP1135SU.UPD
CNPR1110U1.PPD
CNS31U_DFCF3.CHM, CNS31U.CHM

[ADVC5051_FILES]
CNS30M_D7193.DLL,CNS30M.DLL
CNS30MUI_D7193.DLL,CNS30MUI.DLL
CNS30409_D7193.DLL,CNS30409.DLL
IRC504SU.XPD
IRC504SU.UPD
CNADVC5045U1.PPD
CNS31U_D7193.chm, CNS31U.chm

[ADVC5035_FILES]
CNS30M_DB368.DLL,CNS30M.DLL
CNS30MUI_DB368.DLL,CNS30MUI.DLL
CNS30409_DB368.DLL,CNS30409.DLL
IRC503SU.XPD
IRC503SU.UPD
CNADVC5030U1.PPD
CNS31U_DB368.chm, CNS31U.chm

[ADVC7065_FILES]
CNS30M_DE5E0.DLL,CNS30M.DLL
CNS30MUI_DE5E0.DLL,CNS30MUI.DLL
CNS30409_DE5E0.DLL,CNS30409.DLL
IRC705SU.XPD
IRC705SU.UPD
CNADVC7055U1.PPD
CNS31U_DE5E0.chm, CNS31U.chm

[ADVC9065_FILES]
CNS30M_D7279.DLL,CNS30M.DLL
CNS30MUI_D7279.DLL,CNS30MUI.DLL
CNS30409_D7279.DLL,CNS30409.DLL
IRC907SU.XPD
IRC907SU.UPD
CNADVC9065U1.PPD
CNS31U_D7279.chm, CNS31U.chm

[PS_FILES]
AUSSDRV.DLL
CPC10S.DLL
CPC10D.EXE
CPC10Q.EXE
CPC10E.DLL
CPC10V.EXE
CPC1US.DLL
CPC1US.CHM
CnXPCF32.DLL
UCS32P.DLL
CnXPTN32.DLL
CnxD0250.dat

[NETSPOT_CPCA]
AUCPLMNT.DLL,,,0x00000020

[DRVCOPY]
AUCPLMNT.DLL,,,0x00000020

[NETSPOT_COMMON]
CnxDias2.DLL,,,0x00000020

[COLORGEAR_KYNS]
CNKYNS32.DLL
CNRGBVIRTUALDEVICE.DLL
CNRGBPRINTER.DLL
CNPERCEPTUAL.DLL
CNMONITORMATCH.DLL
CNCOLORIMETRIC.DLL
CNSATURATION.DLL

[DestinationDirs]
DefaultDestDir=66000
NETSPOT_CPCA=66002
DRVCOPY=66000

[SourceDisksFiles]
CNS30M.DLL    = 1
CNS30MUI.DLL  = 1
CNS30409.DLL  = 1
AUSSDRV.DLL   = 1
CnXPTN32.DLL  = 1
UCS32P.DLL    = 1
CNKYNS32.DLL  = 1
CNRGBVIRTUALDEVICE.DLL = 1
CNRGBPRINTER.DLL = 1
CNPERCEPTUAL.DLL = 1
CNMONITORMATCH.DLL = 1
CNCOLORIMETRIC.DLL = 1
CNSATURATION.DLL = 1
CNS31U.CHM    = 1
CPC10S.DLL    = 1
CPC10D.EXE    = 1
CPC10Q.EXE    = 1
CPC10E.DLL    = 1
CPC10V.EXE    = 1
CPC1US.DLL    = 1
CPC1US.CHM    = 1
CnXPCF32.DLL  = 1
AUCPLMNT.DLL  = 1
CnxDias2.DLL  = 1
CnxD0250.dat  = 1
IP1135SU.XPD  = 1
IRC504SU.XPD  = 1
IRC503SU.XPD  = 1
IRC705SU.XPD  = 1
IRC907SU.XPD  = 1
IP1135SU.UPD  = 1
IRC504SU.UPD  = 1
IRC503SU.UPD  = 1
IRC705SU.UPD  = 1
IRC907SU.UPD  = 1
CNPR1110U1.PPD  = 1
CNADVC5045U1.PPD = 1
CNADVC5030U1.PPD = 1
CNADVC7055U1.PPD = 1
CNADVC9065U1.PPD = 1

[SourceDisksNames]
1=%DISK1%

[Strings]
CANON="Canon"
NS_LMON_CPCA="CPCA Language Monitor2,AUCPLMNT.DLL"
DISK1="Canon PS3 Printer Driver for Microsoft Windows (x86) Version 20.11 Installer Disk"
Try moving:

net stop spooler
net start spooler

to the end of your script instead of the beginning
Avatar of jmls

ASKER

Tried that, printer is still not appearing.  but the registry keys are.  It was my understanding that the restarting of the spooler was necessary so that the ports would appear.  
I would remark out the last line and run it by hand to see if it throws an error, that is, copy and paste it into a command prompt and then remove the /q option.
According to http://technet.microsoft.com/en-us/library/ee624057(WS.10).aspx, /h should be set to x86, x64 or Itanium.  I personally would just drop the /h and /v options to see if it works.
Also, take a look at this LPR script: http://www.whited.us/portfolio/programs/lpr.bat.txt
Avatar of jmls

ASKER

still isint working getting a Print processor does not exist error.  it seems to be haning on the driver installation
I think you tapped my printer scripting knowledge, perhaps someone else has some ideas?
Avatar of jmls

ASKER

The only thing I can think of is that in my driver installation line there must be something  that isnt jiving with Windows 7,  Im going to test this script on XP and Vista Ill post my results,  it could be some odd UAC feature or a rundll issue.  
Avatar of jmls

ASKER

OK, I figured out most of the issue,  the final script that I have runs perfectly on XP however it appears that vista/win7 use a different method of adding drivers than XP.  
ASKER CERTIFIED SOLUTION
Avatar of jmls
jmls
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial