How to get windows disk device instance path by python?
How to get windows disk device instance path by python?
Hi,How to get windows disk device instance path by python?
Re: How to get windows disk device instance path by python?
You mean Python or MicroPython?
First case you can parse output of e.g.
(your question doesn't specify which device, this will list all of them..)
Second case: you'll have to write something custom for that since popen isn't implemented. E.g. a custom C module which uses win32 API to get the needed information.
First case you can parse output of e.g.
Code: Select all
import os
os.popen('wmic diskdrive get PNPDeviceID').read()
Second case: you'll have to write something custom for that since popen isn't implemented. E.g. a custom C module which uses win32 API to get the needed information.
Re: How to get windows disk device instance path by python?
Thank you very much. Python use code:os.popen('wmic diskdrive').read() . I can get the disk DeviceID and PNPDeviceID. Then I have a new question: How do I know the partition(like:C,D,E,F,G...) of this disk device if I know the DeviceID and PNPDeviceID?stijn wrote: ↑Thu Jan 02, 2020 8:28 amYou mean Python or MicroPython?
First case you can parse output of e.g.
(your question doesn't specify which device, this will list all of them..)Code: Select all
import os os.popen('wmic diskdrive get PNPDeviceID').read()
Second case: you'll have to write something custom for that since popen isn't implemented. E.g. a custom C module which uses win32 API to get the needed information.
Re: How to get windows disk device instance path by python?
Something like this: https://superuser.com/questions/634842/ ... using-wmic or maybe using the Python psutil module
Re: How to get windows disk device instance path by python?
Thank you very much.Helped me a lot.stijn wrote: ↑Thu Jan 02, 2020 1:03 pmSomething like this: https://superuser.com/questions/634842/ ... using-wmic or maybe using the Python psutil module