Page 1 of 2 12>
Topic Options
#170268 - 2006-11-14 10:20 PM Add IP Printer
Lucid Offline
Fresh Scripter

Registered: 2006-09-20
Posts: 11
All,

I am currently trying to cobble together my first Kix login script with the help of some of the excellent UDFs available here. I am running into an issue using the AddPrinter UDF located at http://www.kixtart.org/UDF/UDF_lister.php?what=post&code=83350

The code section in my script reads like this:

Code:

$Mapprn = AddPrinter("10.0.0.103","HP Color LaserJet 2500 PCL 6","C:\clj2500\hp2500p6.inf","HP Colour (Copy Room)")



Whenever it runs I get an error message that "the system could not find the file specified". I'm assuming its having problems with the INF but I'm not sure why. the file is there and in the location specified, I've changed the permissions on it to make sure that everyone has full rights but still no go. Can anyone shed some light on what's going on here (or an alternative method to add an IP printer for a newb like myself).

Thanks in advance.

Top
#170269 - 2006-11-14 10:53 PM Re: Add IP Printer
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Well without really looking at your code just a reminder
that PRINTER NAME and SHARE NAME can be different.

You need to use the correct information.
 
A discussion of it's use from a LONG time ago can be found here.
http://www.kixtart.org/ubbthreads/showflat.php?Cat=0&Number=37276 
 

Top
#170270 - 2006-11-14 11:24 PM Re: Add IP Printer
Lucid Offline
Fresh Scripter

Registered: 2006-09-20
Posts: 11
NTDOC, you are correct, there is something wrong elsewhere in the script. As a test I extracted the problem line and the UDF call to a separate script, and it worked perfectly. So something in the login script seems to be the culprit. I've posted it below, and I'm sure its fraught with errors so please be gentle. But any suggestions in addition to my issue are welcome

Code:

if NOT @LOGONMODE
Break On
EndIf
Dim $RC
; $RC = SetOption("Explicit","On")
$RC = SetOption("NoVarsInStrings","On")
$RC = SetOption("NoMacrosInStrings","On")
$RC = SetOption("WrapAtEOL","On")

Dim $Mapdrv, $Mapprn, $RegTweak

call "\\****\netlogon\UDF\mapdrive.udf"
call "\\****\netlogon\UDF\mapprint.udf"


CLS

? "Mapping Company Share to G: "
$Mapdrv = Mapdrive('G',\\****\company,0,'Company')
@ERROR

IF INGROUP("administrators")
? "Mapping Admin Install Share to X: "
$Mapdrv = Mapdrive('x',\\****\ClientApps,0,'Install Share')
@ERROR
ENDIF

IF INGROUP("MCR Employees")
? "Mapping MCR Share to M: "
$Mapdrv = Mapdrive('M',"\\****\MCRSys$",0,'MCR Share')
@ERROR
ENDIF

? "Performing Registry Tweaks"
? "Setting WinXP Update Path "
WriteValue ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup", "SourcePath", "\\****\ClientApps\Microsoft\WinXP with SP2", "REG_SZ")
If @ERROR = 0
? "Value written to the registry"
Endif



? "Mapping Printers"

$Mapprn = AddPrinter('\\****\fax',"",)
?"Shared Fax "@error ?
$Mapprn = AddPrinter("10.0.0.103","HP Color LaserJet 2500 PCL 6","C:\clj2500\hp2500p6.inf","HP Colour (Copy Room)")
?"CLJ 2500 "@error

IF INGROUP("Students")
$Mapprn = AddPrinter('\\****\HP 3030',"",)
? "MFC HP3030 (Student Area) "@error
ENDIF

Sleep 5




The output I get is the following:

Mapping Company Share to G: 0
Mapping Admin Install Share to X: 0
Mapping MCR Share to M: 0
Performing Registry Tweaks
Setting WinXP Update Path 0
Value written to the registry
Mapping Printers
Shared Fax 0
The system cannot find the file specified.

CLJ 2500 -2

Once again, thanks in advance for your help.

Top
#170271 - 2006-11-15 02:33 AM Re: Add IP Printer
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
From Addprinter()
Quote:


;Returns:
; -4 - Error connecting to RemotePC
; -3 - Could not open/find INF file
; -2 - Could not find $PrinterType in INF file
; -1 - Unrecognized Port






I see a -2 at the end of your output. Make sure your $PrinterType matches the description within the INF file.

Top
#170272 - 2006-11-15 03:05 PM Re: Add IP Printer
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
If you are running this in a LOGIN script, the reference to C:\clj2500\hp2500p6.inf is relative to the user's PC. Unless the login script first copies the INF file to the local systemm, you will get an Error 2 - file not found.

Assuming that the file is in a central location, you should reference it as a UNC path - \\server\share\clj2500\hp2500p6.inf

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#170273 - 2006-11-15 04:26 PM Re: Add IP Printer
Lucid Offline
Fresh Scripter

Registered: 2006-09-20
Posts: 11
Allen and Glen,

Thanks for the replys. Allen, I assumed that the -2 was coming because of the previous error that it couldn't find the file specified, not the printertype. But frankly, I'm a little confused as to what to put for printertype. I'm unfamiliar with how these INFs are setup and I don't see an obvious "description" in the file. Here is an excerpt from the INF, can you tell what I should use as the printertype?

Quote:


;
; hp color LaserJet 2500 PCL 6 driver installation file for MS Windows 2000
; Copyright © Copyright Hewlett-Packard 1996, 1997, 1998, 1999, 2000
; Copyright © OAK Technology, INC. 1998-2000
; All Rights Reserved
;

; Version section
[Version]
Signature="$Windows NT$"
Provider=HP
ClassGUID={4D36E979-E325-11CE-BFC1-08002BE10318}
Class=Printer
CatalogFile=HP2500P6.CAT
DriverVer=05/12/2003,4.20.2500.430

; Manufacturer section
[Manufacturer]
"HP" =HPLaserPrinter,NTx86.5.1.0x03,NTx86.5.1

; Model sections.
[HPLaserPrinter.NTx86.5.1.0x03]
;For Windows Server 2003
%Printer1%=HPBF342I.PMD,USBPRINT\Hewlett-Packardhp_co8E3D,LPTENUM\hewlett-packardhp_co8e3d,DOT4PRT\hewlett-packardhp_co8e3d,DOT4PRT\vid_03f0&pid_0717&rev_0400,hewlett-packardhp_co8e3d

[HPLaserPrinter.NTx86.5.1]
;For WinXP
%Printer1%=HPBF342I.PMD,USBPRINT\Hewlett-Packardhp_co8E3D,LPTENUM\hewlett-packardhp_co8e3d,DOT4PRT\hewlett-packardhp_co8e3d,DOT4PRT\vid_03f0&pid_0717&rev_0400,hewlett-packardhp_co8e3d

[HPLaserPrinter]
;For Win2k
%Printer1%=HPBF342I.PMD,DOT4PRT\Hewlett-Packardhp_co8E3D&BPRINT
%Printer1%=HPBF342I.PMD,DOT4PRT\Vid_03f0&Pid_0717&DOT4&BPRINT,hewlett-packardhp_co8e3d

; Installer Sections
[HPBF342I.PMD]
; To Disable Add Printer Auto Configuration: Remove "AUTOCFG_FILES" from the CopyFiles line below
DataSection=HPBF342I_DATA
CopyFiles=AUTOCFG_FILES,HPBF342I_FILES,LANGMON_FILES,LANGMON_DRVCOPY
DataFile=HPBF342I.PMD

; Data Sections
[HPBF342I_DATA]
DriverFile=HPBF342G.DLL
ConfigFile=HPBF342E.DLL
HelpFile=HPBF342E.HLP
LanguageMonitor=%HPDC_MONITOR%





Glenn, I originally had the file on a network share, but copied the filed over to my c:\ drive for testing. The errors are coming when I run the script manually from my computer.

To further get a handle on what's happening I decided to comment out the script to only leave the followng;

Code:

if NOT @LOGONMODE
Break On
EndIf
Dim $Mapdrv, $Mapprn, $RegTweak
call "\\****\netlogon\UDF\mapprint.udf"
CLS
? "Mapping Printers"

$Mapprn = AddPrinter('\\****\fax',"",)
?"Shared Fax "@error ?
$Mapprn = AddPrinter("10.0.0.103","HP Color LaserJet 2500 PCL 6","C:\clj2500\hp2500p6.inf","HP Colour (Copy Room)")
?"CLJ 2500 "@error

IF INGROUP("Students")
$Mapprn = AddPrinter('\\****\HP 3030',"",)
? "MFC HP3030 (Student Area) "@error
ENDIF

Sleep 5



Now my results are entirely different:

Quote:


Mapping Printers
Shared Fax 0

CLJ 2500 1801





After starting to put lines back it seems that the line
$RC = SetOption("NoVarsInStrings","On")
is the culprit that caused the "cannot find the file specified error" and the -2.

So now two questions, am i correct in assuming the problem with the line above is because somewhere in the UDF there is a variable in a string that needs to be resolved?

And can anyone help me figure out how to get rid of the 1801 error?

Top
#170274 - 2006-11-15 07:26 PM Re: Add IP Printer
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
Not to avoid your questions... but maybe you don't need to use addprinter at all. Your first printer can certainly use the kix built-in addprinterconnection function as it is connecting to a print server. If your second printer is also shared via printserver (even though it is IP) you can also use addprinterconnection.
Top
#170275 - 2006-11-15 08:49 PM Re: Add IP Printer
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
so, what's the type?
Top
#170276 - 2006-11-15 11:14 PM Re: Add IP Printer
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
As for pulling the $Printertype name...

For example: opening the %windir%\inf\ntprint.inf file you will see all kinds of information. Usually within it there is a section of Printernames with the associated file and something like a deviceid... Just copy the relevent printer name (everything to the left of equals sign) into your script...see below.

Quote:


[HP]
"Hewlett-Packard HP-GL/2 Plotter" = HPGL2PEN.PCD ,HPHewlett-Packard_HP7319,Hewlett-Packard_HP-GL/2_Plotter
"HP 2000C" = HPV2000C.GPD.ICM ,HEWLETT-PACKARDHP_206454,HP_2000C
"HP 2500C Series" = HPWM5250.GPD.ICM ,HEWLETT-PACKARDHP_25A854,HP_2500C_Series
"HP 2500C Series PCL5Ce" = MS_HPWM525P.GPD.ICM ,HPHP2500C_Series5601,HP_2500C_Series_PCL5Ce
"HP 2500C Series PS3" = HPWM5P25.PPD ,HPHP_2500C_Series_PS38B8,HP_2500C_Series_PS3
"HP D 640" = HPD640.GPD ,Hewlett-PackardHP50067AC,HP_D_640
"HP 7550 Plus" = HP7550PL.PCD ,HPHP_7550_Plus04A9,HP_7550_Plus
"HP Business Inkjet 2200/2250 (HPA)" = MS_HPWM5220.GPD ,HEWLETT-PACKARDHP_BUE038,HP_Business_Inkjet_2200/2250_(HPA)
"HP Business Inkjet 2250 (PCL5C)" = MS_HPWM5225.GPD.ICM ,HEWLETT-PACKARDHP_BUB03B,HP_Business_Inkjet_2250_(PCL5C)
"HP Business Inkjet 2250 (PS)" = MS_HPWM5225.PPD.ICM ,HPHPBusiness_Inkjet_22F6E5,HPBusiness_Inkjet_22F6E5,HP_Business_Inkjet_2250_(PS)
"HP C LaserJet 4500-PS" = HP4500.PPD ,HPHP_C_LaserJet_4500FA91,HP_C_LaserJet_4500-PS
"HP Color LaserJet 4500" = HPC4500.GPD.ICM ,Hewlett-PackardHP_Co3115,HP_Color_LaserJet_4500
"HP Color LaserJet" = HPCLJ.GPD.ICM ,HPHP_Color_LaserJet67C4,HP_Color_LaserJet
"HP Color LaserJet PS" = HP__CLJ1.PPD.ICM ,HPHP_Color_LaserJet_E227,HP_Color_LaserJet_PS
"HP Color LaserJet 4550 PCL" = MS_HPC4550.GPD.ICM ,Hewlett-PackardHP_Co16E1,HP_Color_LaserJet_4550_PCL
"HP Color LaserJet 4550 PCL" = MS_HPC4550.GPD.ICM ,HWPC211, HP_Color_LaserJet_4550
"HP Color LaserJet 4550 PS" = MS_HP4550_6.PPD ,HPHPColor_LaserJet_4556C7C,HPColor_LaserJet_4556C7C,HP_Color_LaserJet_4550_PS
"HP Color LaserJet 5" = HPCLJ5D.GPD ,Hewlett-PackardHP_Co01FC,HP_Color_LaserJet_5
"HP Color LaserJet 5M" = HPCLJ5MD.GPD.ICM ,HPHP_Color_LaserJet_BA8C,HP_Color_LaserJet_5M
"HP Color LaserJet 5/5M PS" = HPCLJ5V2.PPD.ICM ,Hewlett-Packard71C4,HP_Color_LaserJet_5/5M_PS
"HP Color LaserJet 8500 PCL" = MS_HPC8500.GPD.ICM ,Hewlett-PackardHP_Co6116, HP_Color_LaserJet_8500
"HP Color LaserJet 8500 PS" = HP_CLJ85.PPD ,HPHP_Color_LaserJet_54E1,HP_Color_LaserJet_8500_PS
"HP Color LaserJet 8550 PCL" = MS_HPC8550.GPD.ICM ,HEWLETT-PACKARDHP_Co17F1,Hewlett-PackardHP_Co17F1,HP_Color_LaserJet_8550_PCL
"HP Color LaserJet 8550-PS" = MS_HP8550_7.PPD ,HPHPColor_LaserJet_855B691,HPColor_LaserJet_855B691,HP_Color_LaserJet_8550-PS
"HP CopyJet" = HPCPJET.GPD ,HPHP_CopyJet0DF2,HP_CopyJet
"HP CopyJet M/PS" = HPCOPYJ1.PPD ,HPHP_CopyJet_M/PSECF5,HP_CopyJet_M/PS




Top
#170277 - 2006-11-15 11:35 PM Re: Add IP Printer
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
but this works only for printers already in the windows drivers collection.
doesn't look at all same as the inf shown previously.

Top
#170278 - 2006-11-15 11:49 PM Re: Add IP Printer
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
that's the point... here is what it is supposed to look like...

what he quoted is "an excerpt" so its missing the rest of the file.

Top
#170279 - 2006-11-16 05:54 AM Re: Add IP Printer
Lucid Offline
Fresh Scripter

Registered: 2006-09-20
Posts: 11
I need to use the IP rather than printserver option as a test for a future re-use of the script at a location that wont have a print server.

Can we assume that the printertype is correct since the error isn't -2? Or can an 1801 error be traceable to an incorrect printertype as well? Is there something else to check?

I've scoured the INF for the correct printertype but nothing matches up to the example. I'll quote the whole thing (using code to keep it small). Can you figure out what to use?

Code:

;
; hp color LaserJet 2500 PCL 6 driver installation file for MS Windows 2000
; Copyright © Copyright Hewlett-Packard 1996, 1997, 1998, 1999, 2000
; Copyright © OAK Technology, INC. 1998-2000
; All Rights Reserved
;

; Version section
[Version]
Signature="$Windows NT$"
Provider=HP
ClassGUID={4D36E979-E325-11CE-BFC1-08002BE10318}
Class=Printer
CatalogFile=HP2500P6.CAT
DriverVer=05/12/2003,4.20.2500.430

; Manufacturer section
[Manufacturer]
"HP" =HPLaserPrinter,NTx86.5.1.0x03,NTx86.5.1

; Model sections.
[HPLaserPrinter.NTx86.5.1.0x03]
;For Windows Server 2003
%Printer1%=HPBF342I.PMD,USBPRINT\Hewlett-Packardhp_co8E3D,LPTENUM\hewlett-packardhp_co8e3d,DOT4PRT\hewlett-packardhp_co8e3d,DOT4PRT\vid_03f0&pid_0717&rev_0400,hewlett-packardhp_co8e3d

[HPLaserPrinter.NTx86.5.1]
;For WinXP
%Printer1%=HPBF342I.PMD,USBPRINT\Hewlett-Packardhp_co8E3D,LPTENUM\hewlett-packardhp_co8e3d,DOT4PRT\hewlett-packardhp_co8e3d,DOT4PRT\vid_03f0&pid_0717&rev_0400,hewlett-packardhp_co8e3d

[HPLaserPrinter]
;For Win2k
%Printer1%=HPBF342I.PMD,DOT4PRT\Hewlett-Packardhp_co8E3D&BPRINT
%Printer1%=HPBF342I.PMD,DOT4PRT\Vid_03f0&Pid_0717&DOT4&BPRINT,hewlett-packardhp_co8e3d

; Installer Sections
[HPBF342I.PMD]
; To Disable Add Printer Auto Configuration: Remove "AUTOCFG_FILES" from the CopyFiles line below
DataSection=HPBF342I_DATA
CopyFiles=AUTOCFG_FILES,HPBF342I_FILES,LANGMON_FILES,LANGMON_DRVCOPY
DataFile=HPBF342I.PMD

; Data Sections
[HPBF342I_DATA]
DriverFile=HPBF342G.DLL
ConfigFile=HPBF342E.DLL
HelpFile=HPBF342E.HLP
LanguageMonitor=%HPDC_MONITOR%

; Copy Sections
[HPBF342I_FILES]
HPBF342E.DLL,HPBF342E.DL_
HPBF342G.DLL,HPBF342G.DL_
HPBF342I.PMD,HPBF342I.PM_
HPBF342E.HLP,HPBF342E.HL_
HPBAFD32.DLL,HPBAFD32.DL_
HPBFTM32.DLL,HPBFTM32.DL_

[AUTOCFG_FILES]
HPNRA.EXE,HPNRA.EX_
HPBOID.EXE,HPBOID.EX_
HPBPRO.EXE,HPBPRO.EX_
HPPAPML0.EXE,HPPAPML0.EX_
HPBNRAC2.DLL,HPBNRAC2.DL_
HPBMIAPI.DLL,HPBMIAPI.DL_
HPBOIDPS.DLL,HPBOIDPS.DL_
HPBPROPS.DLL,HPBPROPS.DL_
HPJCMN2U.DLL,HPJCMN2U.DL_
HPJIPX1U.DLL,HPJIPX1U.DL_
HPPAPTS0.DLL,HPPAPTS0.DL_
HPPASNM0.DLL,HPPASNM0.DL_
HPPAPML0.DLL,HPPAPML0.DL_
HPBMINI.DLL,HPBMINI.DL_
HPBF342G.HPI,HPBF342G.HP_

[LANGMON_FILES]
HPBMMON.DLL,HPBMMON.DL_
HPDOMON.DLL,HPDOMON.DL_
HPBHEALR.DLL,HPBHEALR.DL_

[LANGMON_DRVCOPY]
HPBMMON.DLL,HPBMMON.DL_
HPDOMON.DLL,HPDOMON.DL_
HPBHEALR.DLL,HPBHEALR.DL_

[DestinationDirs]
DefaultDestDir=66000
HPBF342I_FILES=66000
LANGMON_DRVCOPY=66000
LANGMON_FILES=66002
AUTOCFG_FILES=66000

; Localizable Strings
[Strings]
Printer1="HP Color LaserJet 2500 PCL 6"
DiskID1="hp color LaserJet 2500 PCL 6 Disk 1"
DiskID2="hp color LaserJet 2500 PCL 6 Disk 2"
HPDC_MONITOR="HP Master Monitor,HPBMMON.DLL"

; Sourcedisks section
[SourceDisksNames.x86]
1 = %DiskID1%,,,""
2 = %DiskID2%,,,""

[SourceDisksFiles.x86]
HPBF342E.DL_=2
HPBF342G.DL_=1
HPBF342I.PM_=1
HPBF342E.HL_=1
HPBAFD32.DL_=1
HPBFTM32.DL_=1
HPNRA.EX_ =1
HPBOID.EX_ =1
HPBPRO.EX_ =1
HPPAPML0.EX_=1
HPBNRAC2.DL_=1
HPBMIAPI.DL_=1
HPBOIDPS.DL_=1
HPBPROPS.DL_=1
HPJCMN2U.DL_=2
HPJIPX1U.DL_=1
HPPAPTS0.DL_=1
HPPASNM0.DL_=1
HPPAPML0.DL_=1
HPBMINI.DL_ =2
HPBF342G.HP_=1
HPBMMON.DL_ =1
HPBMMON.DLL =1
HPDOMON.DL_ =1
HPBHEALR.DL_=1


Top
#170280 - 2006-11-16 06:02 AM Re: Add IP Printer
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
Curious stuff... definately don't have the section needed for Addprinter to work.

Not sure what to tell you. You might look and see if you can find another set of drivers and see if it has a different inf file.

Top
#170281 - 2006-11-16 06:04 AM Re: Add IP Printer
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
On second look, it looks like it might be "HP".
Top
#170282 - 2006-11-16 07:17 AM Re: Add IP Printer
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
lol, allen, I've been looking at that too.
Top
#170283 - 2006-11-16 08:09 AM Re: Add IP Printer
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
Lucid, you've definately got a point on the novarsinstrings issue. I wrote this thing more than 2 years ago and have not revisted it, or used it since. I see at least two vars in strings. Maybe Saturday, while I'm watching football all day, I can sit down and tidy this thing up a little.
Top
#170284 - 2006-11-17 06:44 AM Re: Add IP Printer
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
Lucid... I've posted a newer version. Would you mind giving it a try?

BTW... After looking (and looking) at your inf, I think the $printertype is "HP Color LaserJet 2500 PCL 6"

Top
#170285 - 2006-11-17 11:25 AM Re: Add IP Printer
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
so he had correct type in his last test?
Top
#170286 - 2006-11-17 01:46 PM Re: Add IP Printer
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
Quote:

so he had correct type in his last test?




we will have to wait and see... I can't be sure just yet.

Top
#170287 - 2006-11-22 12:35 AM Re: Add IP Printer
Lucid Offline
Fresh Scripter

Registered: 2006-09-20
Posts: 11
Sorry for the delayed reply. Many fires to put out that have delayed me revisiting this.

I have tested the new script and it seems to work beautifully (i used the full name of the printer for printertype). Now I just need to test it again in the other environment and we should be good to go. Thank you SO MUCH for your help.

Top
Page 1 of 2 12>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 259 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.087 seconds in which 0.028 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org