How to find USB history on your computer
In Microsoft windows almost everything is stored in registry as a key value pair. If you want to explore something you can go to registry by typing "REGEDIT" in run or command prompt.
Here I am going to explain how you can find the list of USB used in a particular systems till date. You will be able to list all the devices which are used in the particular computer if registry values are not altered. Follow the below path to open the registry place where all the history of USB devices stored.
"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ENUM\USBSTOR"
Open the registry and go to the above path you will find something like shown in below figure:
Here you will see list of all the devices which are used as a USB. Now see names are not readable . So expand each node and select the child node , you will see details in the right panel , now observe the key "FriendlyName", you will find the exact name of the USB device. Here is screen print of the same :
Now it looks very simple to find as explained above. Suppose there is a requirement to find this list in your program or programmatically you want to find this list then?
I have created a simple python script through which you can iterate registery key values and can find whatever you want. See the below code.
from winreg import * aReg = ConnectRegistry(None,HKEY_LOCAL_MACHINE) bKey = OpenKey(aReg,r"SYSTEM\CurrentControlSet\ENUM\USBSTOR") for j in range(1024): try: asubkey_name=EnumKey(bKey,j) asubkey=OpenKey(bKey,asubkey_name) bsubkey_subkey_name=EnumKey(asubkey,0) bsubkey=OpenKey(asubkey,bsubkey_subkey_name) val=QueryValueEx(bsubkey,"FriendlyName") print(val) except EnvironmentError: break
Nice and well articulated article..liked it
ReplyDelete