Thanks a lot Jan
I have found some examples about how to lock and unlock Usb devices on a Windows machine using HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UsbStor registry key and usin devcon tools.
All the examples I have been able to find are for a manager-like executable in which you disable or enable usb access by changing registry key before you do something.
But what I intend to do is writing a program wit C# like a windows service that locks usb access completely at start-up and spots if a usb device is plugged then ask for a password and if the password is correct allow access. But here is my problem;
When you disable usb devices by changing registry key and using devcon tools, all the plugged usb devices are still disabled and invisible to windows and vice-versa; if you disable usb access, all previously plugged devices are still accessable.both of working with devcon tools and change the registry key are require the restart and I dont want this act be happened.
This issue my "plug, enter password, use" concept impossible.
Can anyone point me at the right direction where I can(if I can) make windows re-scan plugged usb devices for all usb ports or for a specified port so that it wont be necessary to unplug&replug usb devices after entering password or a way to disable a specified usb port/hub, not all of them programmatically? Any other suggestions are also greatly appreciated.
Thank you.