Webusb: Access Denied trying to open printer on Windows
Asked Answered
V

2

7

I am trying to allow a POS web app to print directly to a StarMicronics (or any receipt printer, for that matter) using the Chrome webusb API.

I am using the example here almost exactly except I have modified the vendorId filter to the Vendor ID of StarMicronics. I have also tried it with a completely empty filter. It works great on the Mac computers I have tested it on, but the problem is on Windows.

When I click the print button, Chrome opens up the connection window, my device is listed and I can select it and click Connect. So navigator.usb.getDevices() is working great. When I refresh the window, after having connected the website to the device, Chrome finds the device again with no problem.

The problem comes when I try to do device.open(). I get this error in the console: DOMException: Access Denied. From this point, I can't do either device.selectConfiguration() or device.claimInterface() because I get the error that the device must first be opened, obviously.

I have enabled all the flags I know of in Chrome: #enable-experimental-web-platform-features #enable-webusb #new-usb-backend

But none of this has helped. I have also tried using other printers, such as an HP deskjet and a Dymo Label Writer all with the same resulting error message that access is denied.

Again, it is working fine on Macs.

Any help on this would be greatly appreciated.

Vigilante answered 6/11, 2017 at 18:9 Comment(1)
Did you cleared this issue. Even i am facing same issue could you please help mePlayback
H
5

You get the "Access Denied" error on Windows because there is already a driver that has claimed the device. The Windows driver model requires that the "winusb.sys" driver be loaded for any device that will be accessed by a userspace application like Chrome.

See my answer to this earlier question about smartcard readers which encounter the same difficulty on Windows.

Haland answered 7/11, 2017 at 1:44 Comment(2)
Ah, yes, I had seen that one, but since his error was with claiming the device (and I'm having no trouble doing that) but with opening it, I didn't think it applied to my situation. Thanks, I'll try it out today and see what I can come up with.Vigilante
So, I had downloaded the zadig utility, so I removed the printer from Windows printers, opened up zadig and made sure the WinUSB (v6.1.7600.16385) driver is installed and that it's not showing up in the Windows printers but I'm still getting the same error. Please note again, it's not with claiming the device, that works fine, it's with trying to open the device, and I'm getting a slightly different error than the person in your other answer. Maybe I'm still doing something wrong, I'm not familiar with this usb stuff.Vigilante
L
2

You'll need to first download the Star Micronics Windows Driver (available here for the SP700). You want the "USB Vendor Class Driver" (again, available here for the SP700)

Of course, there is no auto-installer (to my knowledge), so you'll have to open up the StarUSBVendorClassDriver_... zipped folder, and navigate to Manuals/usb-vendor-class-driver_im_en.pdf.

In reading this, you'll notice that you actually need to install the driver from the CMD line with the following cmd (note the <version_here>, don't COPY+PASTE):

pnputil -a StarUSBVendorClassDriver_<version_here>\USBVendorClassDriver\SMJUSBCOM.INF

Once you have the correct driver installed, download the Zadig utility from the download page here. The website is ad-ridden, but I had no problems.

Open Zadig, toggle the "Options" menu dropdown, and toggle "List All Devices".

Zadig Options Dropdown

You should then see your device in the drop down below. Select it as shown below.

Select Printer

Then, on the LHS dropdown, you will see a "non WinUSB" driver selected. On the RHS, ensure that WinUSB is selected, and click "Replace Driver".

Select Driver

This should enable WebUSB! Happy printing!

Leung answered 1/6, 2022 at 23:58 Comment(2)
Note - this setup has also been verified to work when printing via WebUSB to an Epson TM-T88VI as well.Leung
So this is the only way for those printer with driver in order to access via WebUSB?Epagoge

© 2022 - 2024 — McMap. All rights reserved.