pythonwinapisystemdisk

Find System Hard Disk Drive from Python?


I am working on a software installer for my current application. It needs to be installed to the System HDD. How owuld I detect the system drive and return the letter from Python?

Would the win32 extensions be useful? How about the os module pre packaged with Python?


Solution

  • This is how to return the letter of the System drive on a Win32 platform:

    import os
    print os.getenv("SystemDrive")
    

    The above snippet returns the system drive letter. In my case ( and most cases on windows) C: