What is the best way to map a network share to a windows drive using Python? This share also requires a username and password.
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 all the information is static.