WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Printer Controller

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

pSetPrtInfo - Error 507

 Keywords: pSetPrtInfo 507 Unable to access specified printer 

Question #1:

When running the following code:
AddExtender("WWPRT34i.DLL")
p = "\\bvlw2k12\IC-324-HP5SI"
pSetPrtInfo(p, 4, "LPT1")
I receive Error 507, Unable to access specified printer.

Following is what I receive from pGetPrtList:

\\bvlw2k12\IC-324-HP5SI IC-324-HP5SI HP LaserJet 5Si
\\bvlw2k12\IC-324-HP5SI
Any ideas?

Reply #1:

Not sure.
  1. Is that printer actually available? Can you print to it?

  2. Does pGetPrtInfo work?

  3. What extended error information does this return?:
    ErrorMode(@OFF)
    pSetPrtInfo(p, 4, "LPT1")
    errcode = pGetErrorCode()
    errmsg = pGetErrorMsg()
    Message(errcode, errmsg)
    

  4. Find the file wwwbatch.ini in the windows directory and post the LastError line under the heading [wwprt34i.dll]. (if there is any)


Question #2

Following is the text from wwwbatch.ini:
[WWWNT34I]
LastError=1385 (LogonUser)
The printer is available and I can print to it.

pGetPrtInfo does work, and returns the name \\bvlw2k12\IC-324-HP5SI for request #2

The following code:

ErrorMode(@OFF)
pSetPrtInfo(p, 4, "LPT1")
errcode = pGetErrorCode()
errmsg = pGetErrorMsg()
Message(errcode, errmsg)
Returns:
Errcode = 5
Errmsg = Access is denied.

I am a member of the Administrators group for the local machine.

What I am wondering now, is if this is trying to make this change on the print server, instead of my local W2K machine???

What I am trying to do is set an LPT port for a network printer on my local machine. We still have some programs running which require the port to print to. If I can get this to work, I will be able to setup printers on about 3000 machine upgrades automatically, which wil make my boss very happy.

Thanks for the help.

Reply #2

What I am wondering now, is if this is trying to make this change on the print server, instead of my local W2K machine???

Yes, pSetPrtInfo changes the properties of the specified printer.

What I am trying to do is set an LPT port for a network printer on my local machine.

Has the printer already been installed on the local machine? If so, you can just use w95AddPrinter or wntAddPrinter (in the Win95 or WinNT extender) to map the LPT port.


Question #3

I actually run 2 programs:

The first one gets existing printer information from the machine which is being replaced (Windows 95 or 2000), and builds a file similar to the following:

HP LaserJet 5P \\Ppnov\.IC_211_LJ5P.ic.bvl.ok.us.ppco HP LaserJet 5P \\Ppnov\.IC_211_LJ5P.ic.bvl.ok.us.ppco
HP LaserJet 4M \\Ppnov\.IC_341_LJ5SI.ic.bvl.ok.us.ppco HP LaserJet 4M \\Ppnov\.IC_341_LJ5SI.ic.bvl.ok.us.ppco
HP LaserJet 4Si - Copy 2 LPT2: HP LaserJet 4Si LPT2:
HP LaserJet 5Si \\Bvl57\IC_324_HP5SI HP LaserJet 4Si \\Bvl57\IC_324_HP5SI
HP LaserJet Series II LPT1: HP LaserJet Series II LPT1:
Rendering Subsystem PUB: Microsoft Fax Driver PUB:
Microsoft Fax FAX: Microsoft Fax Driver FAX:
LPT2 \\PPNOV\.IC_324_HP5SI.ic.bvl.ok.us.ppco
LPT3 \\PPNOV\.IC_341_LJ5SI.ic.bvl.ok.us.ppco
LPT4 \\PPNOV\.IC_211_LJ5P.ic.bvl.ok.us.ppco
Default LPT2:

The first 7 lines are using pGetPrtList, the next 3 lines are from the registry, and the last line is from pGetDefPrtInf(4).

The 2nd program reads this file from a network drive, and adds the printers back to the Windows 2000 machine, using print queues on a W2K print server. I had hoped to add the printers using pAddPrtConn, determine which printers used LPT port assignments and assign them using pSetPrtInfo, and then set the defaut printer using pSetDefPrt. Doing this way seemed to flow fairly logically, based on the text file above. I have it all written, and everything else works fine.

I will look at changing my program to use wntAddPrinter, but I do not look forward to throwing everything I have already written away.

Reply #3

I don't think you would need to change anything else, just replace pSetPrtInfo with wntAddPrinter.


Question #4

I can make wntAddPrinter work, but do you have any ideas why the pSetPrtInfo way would not work?

The problem with wntAddPrinter, is that if you go look at the list of available ports to print to in the printer properties, the LPT does not show up as being assigned. I can program around this, but was hoping pSetPrtInfo would set the property on the printer properties.

Reply #4

I can make wntAddPrinter work, but do you have any ideas why the pSetPrtInfo way would not work?

Because you didn't have permission to change the properties of the network printer, hence the Access Denied error you received. If you changed it to specify a local printer, then it would probably work.

The problem with wntAddPrinter, is that if you go look at the list of available ports to print to in the printer properties, the LPT does not show up as being assigned.

I don't think pSetPrtInfo would let you specify a non-existent port either.


Question #5

Because you didn't have permission to change the properties of the network printer, hence the Access Denied error you received. If you changed it to specify a local printer, then it would probably work.

So maybe I need some training... I was assuming that I was "setting up" the printer on my local machine, and therefore was trying to make a change to it. But I think you are telling me that in 2000, my machine is looking at the network printer as just another "port".

I don't think pSetPrtInfo would let you >specify a non-existent port either.

I think you are correct on this, my only point is that now I have no way of knowing if the LPT is pointed to a Queue, without going through the registry, or doing Net Use... Not a big deal, just a little additional training for the helpdesk folks. However, since I "saw the light above"... I understand why now.

Thanks for all the help!!!

Reply #5

So maybe I need some training... I was assuming that I was "setting up" the printer on my local machine, and therefore was trying to make a change to it. But I think you are telling me that in 2000, my machine is looking at the network printer as just another "port".

pSetPrtInfo changes the properties of the actual physical printer that you specify. So changing the port would change the printer port on the machine the printer is connected to. What you want to set is the properties of the local connection to that network printer. The terminology is confusing. We have to decide what "printer" means.

I think you are correct that pSetPrtInfo would NOT let you specify a non-existent port , my only point is that now I have no way of knowing if the LPT is pointed to a Queue, without going through the registry, or doing Net Use... Not a big deal, just a little additional training for the helpdesk folks. However, since I "saw the light above"... I understand why now.

You could also use wntGetCon("LPT1"). If it returns anything other than a blank string, the local port is mapped to a print queue.


Article ID:   W14786
File Created: 2001:11:08:12:40:00
Last Updated: 2001:11:08:12:40:00