Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am working on project which is currently on unix platform and we are going to port that project on windows.

I want to know if there is any windows equivalent to following

df -T             

I also want to get all disk information

Serial Number
Check if volume is system volume

I tried reading above information GetVolumeInformation function but I want it to be in pure Python code.

In unix for authentication I used PAM module but its not available in windows I dont find (Tried NTLM but donno is it good way) any good equivalent to it.

Strict Note: Only use inbuild API's and Python 2.6.*

share|improve this question
What have you tried? Under Windows, pseudo-devices like /proc do not exist. Therefore, a "pure Python" solution probably is not feasible. One has to use Win32api (or WMI) calls. Example:… – Axel Kemper Feb 27 '14 at 13:47
@AxelKemper I tried all that but I want to stick to core python 2.6 utilities only.No other modules are allowed to use – Vishakha Ingole Feb 28 '14 at 5:38
up vote 1 down vote accepted

The /proc filesystem does not exist on MS windows.

If you want to stick to built-in stuff in Python, you'll have to make to with what you can find from the os and platform modules.

Alternatively, you can use the built-in ctypes module to call functions from MS windows' Kernel32.dll. That way you can extract equivalent information, if available. It would probably be wise to encapsulate this platform specific stuff in a utility module. That would either read /proc files or call Kernel32.dll functions depending on the value of e.g platform.system().


For finding information about disks and volumes (windows-speak for filesystems) look at MS info about local filesystems.

I'd say you could start with GetLogicalDriveStrings, then GetVolumeInformation. Then use other volume management functions.


This is an example of using ctypes. I don't have a windows machine available to test it, though. According to the docs, the prototype for GetLogicalDriveStrings is:

DWORD WINAPI GetLogicalDriveStrings(
  _In_   DWORD nBufferLength,
  _Out_  LPTSTR lpBuffer

A DWORD is a 32-bit unsigned int. It depends on the platform, but this is usally made with c_uint in ctypes. An LPTSTR is a pointer to a memory area to store stuff. We can use create_string_buffer to make that. It should work something like this

import ctypes

blen = ctypes.c_uint(128)
rv = ctypes.c_uint()
bufs = ctypes.create_string_buffer(128)
rv = ctypes.windll.kernel32.GetLogicalDriveStrings(blen, bufs)
if rv.value == 0:
    raise ValueError('GetLogicalDriveStrings returned 0.')
drives = bufs.raw.split('\0')
drvstring = ' '.join(drives)
print drvstring

The name drives should now reference a list of drive names.

share|improve this answer
Can you please explain how to get volume details (filesystem, serial number, size,)? – Dipak Ingole Mar 2 '14 at 4:42
@Pilot See updated answer. – Roland Smith Mar 2 '14 at 12:16
@RolandSmith any good reference book on how to use this api calls with python? – Vishakha Ingole Mar 3 '14 at 10:08
@VishakhaIngole For starters, look at the ctypes documentation that I linked to. And google for 'ctypes tutorial'. – Roland Smith Mar 3 '14 at 21:22
Thanks my dear @Rolu..Hope you dont mind me calling Rolu..Ronald – Vishakha Ingole Mar 4 '14 at 9:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .