Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

Installing Bluetooth Printer Drivers on newly created COM port

$
0
0

Originally posted to stackoverflow

I am working on a WPF application that needs to pair a bluetooth printer and then subsequently install the printer drivers for that printer. The printer in question is an RW 420. I am using InTheHand.NET to successfully pair with the printer already.

Currently, I am calling this process to install the printer driver:

Process proc = new Process();
proc.StartInfo.FileName = "cscript";
proc.StartInfo.WorkingDirectory = "C:\\Windows\\System32";
proc.StartInfo.Arguments = "C:\\Windows\\System32\\Printing_Admin_Scripts\\en-US\\prnmngr.vbs -a -p \"ZDesigner RW 420\" -m \"ZDesigner RW 420\" -r " + Port + ":";
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.Start();
proc.WaitForExit();
proc.Close();

This process installs the printer successfully as long as the COM Port assigned to the bluetooth device is a pre-existing one. However, the device occasionally assigns the device to a new COM Port such as COM5COM6, etc. When this happens, I can not install the printer via the prnmngr.vbs without first restarting the computer.

Running this process in the command line gives me the following error:

C:\Users\SOMEUSER>cscript C:\Windows\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs -a -p "ZDesigner RW 420" -m "ZDesigner RW 420" -r COM7:
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.

Unable to add printer ZDesigner RW 420 Error 0x80041001 Generic failure
Operation PutInstance
Provider Win32 Provider
Description The specified port is unknown.
Win32 error code 1796

Once I restart the device, this command will work properly.

I don't think this is relevant for the question, but in case it is, the pairing code:

if (device.ClassOfDevice.Device == DeviceClass.ImagingPrinter)
    device.SetServiceState(BluetoothService.SerialPort, true);

BluetoothWin32Authentication authenticator = new BluetoothWin32Authentication(device.DeviceAddress, "0000");


Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>