What is the best way to map windows drives using Python?

Building off of @Anon’s suggestion: # Drive letter: M # Shared drive path: \\shared\folder # Username: user123 # Password: password import subprocess # Disconnect anything on M subprocess.call(r’net use m: /del’, shell=True) # Connect to shared drive, use drive letter M subprocess.call(r’net use m: \\shared\folder /user:user123 password’, shell=True) I prefer this simple approach, especially if … Read more

Combine `Get-Disk` info and `LogicalDisk` info in PowerShell?

You need to query several WMI classes to get all information you want. Win32_DiskDrive gives you information about the physical disks. Win32_DiskPartition gives you information about the partitions on the physical disks. Win32_LogicalDisk gives you information about the filesystems inside the partitions. Partitions can be mapped to their disks using the Win32_DiskDriveToDiskPartition class, and drives … Read more