I am trying to return the host name for a computer given a directory path. I know how to return the computer that my script is executing on,
print os.getenv('COMPUTERNAME')but I want to determine the name of a computer give a path like "Z:\"
Any ideas?
Thanks!
since no one else has responded...
i don't know python well enough to know if there's a "built-in"
command for that, but you can always fall back to piping:net use > test
or: net use | find " $drivelettr:" > test
then you have to open/read/parse test and get the data, which should not be hard for Python to do.
If you have the pywin32 modules, you can use WNetOpenEnum and WNetEnumResource to enumerate your network disks. There's even a C example on MS Support.
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |