Is there any way to eject USB printer connected to device programmatically.
My aim is to prevent user accessing sensitive data through Pendrive/Mobile/Printing it to document.
As of now, I can block pendrive using USBSTOR registry value and Mobile devices using WPD api. But for printer both are not working.
This is not secure. You need to have the system administrator disable the printer for the user. If you disable it with a program, the user can re-enable it easily, and you are but a printscreen into paint away from having the secured data lost. You also need to block email, access to file-dump websites, and a bunch of other things -- email over website, for example.. Protecting data on a machine that has not been locked up by an admin account is like trying to keep water in a sieve by plugging all the holes with your fingers.
I suppose you can make a program to kill the printer for an account using admin settings but that is more trouble than using the tools provided to do the same.