1

I'm trying to map my students personal folders on the shared drive. I really don't want to do this one at a time and have very limited networking experience so thought I'd python it.

#ADDRESS GENERATION

path = r'\\10.38.10.22\04.Simon'
address = (os.path.join(path,name))
function = 'net use z: '
mapdrive = function + address
os.makedirs((address), 0o222)

#MAP FOLDER

time.sleep(3)
subprocess.call(r'net use z: /del /Y', shell=True)
subprocess.call(r'%s' %mapdrive, shell=True)

The name variable is filled out before this with student details.

If I print the path using the variables it comes out fine.

If I print the path using the r'%' %mapdrive line, it prints out correctly too. But no mapped drive. If I run the command manually with no variables, it maps the drive fine.

I thought maybe it was trying to map the folder before it was created, so I put in a 3 second wait but didn't help. I've tried a lot of variations of this code and nothing I've managed other than manually entering all the details into the raw string seems to work.

Help please?

0 Answers0