How to Programatically install UMDF drivers

I have virtual serial port driver UMDF. Now i can install it using pnputil and using add legacy driver option in device manager in win10.
#1.How to programatically install it using C++?
#2.Each time when i add new legacy device, i get new COM port (COM3, COM4). How to specific COM number during installation. Or if it not possible to specify COM number, how to get COM number programatically after it is installed?

Look at the devcon sample, specifically implementation of the “install” command line flag. devcon install does exactly what the add legacy driver option in device manager does. As for driver package installation outside of manual creation of the virtual device, read https://docs.microsoft.com/en-us/windows-hardware/drivers/install/updating-driver-files and choose from UpdateDriverForPlugAndPlayDevices, DiInstallDriver, and DiInstallDevice

1 Like

Thanks, it was really helpful