Good Afternoon,
I used a version of this method to map a dozen drive letters:
# Drive letter: M
# Shared drive path: \\shared\folder
# Username: user123
# Password: password
import subprocess
# Disconnect anything on M
subprocess.call(r'net use * /del', shell=True)
# Connect to shared drive, use drive letter M
subprocess.call(r'net use m: \\shared\folder /user:user123 password', shell=True)
The above code works great as long as I do not have a folder with a file in use by a program.
If I run the same command just in a cmd window and a file is in use when I try to disconnect the drive it returns the Are you sure? Y/N.
How can I pass this question back to the user via the Py script (or if nothing else, force the disconnect so that the code can continue to run?