### Thread: Map a network drive

1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Dec 2012
Posts
5
Rep Power
0

#### Map a network drive

I would like some help mapping a windows 8 drive from python
Can anyone help ?
2. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Nov 2013
Posts
5
Rep Power
0
Hi,

Look in to using the OS and SYS libraries which come with Python as standard. You can run code for CMD, through python.

The CMD code for mapping a network drive is:

Code:
net use X:\ C:\the\directory\you\are\mapping\to
Originally Posted by TamPepper
I would like some help mapping a windows 8 drive from python
Can anyone help ?
3. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Dec 2012
Posts
5
Rep Power
0
I was using the net use X: \\192.168.0.11\Volume_1
from the cmd prompt but am getting a syntax error in Python at the "use"

import sys
import os
net use X: \\192.168.0.11\Volume_1
4. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Nov 2013
Posts
5
Rep Power
0
It's because you're trying to code with script language used in batch files, in a Python file. So Python is trying to work what to do, hence the syntax error.
You need to use the OS module to run the script, like so:

Code:
import os
os.system(r"net use z: \\computer\folder")
Try that, just realised, you probably don't need "sys" for this to work

Originally Posted by TamPepper
I was using the net use X: \\192.168.0.11\Volume_1
from the cmd prompt but am getting a syntax error in Python at the "use"

import sys
import os
net use X: \\192.168.0.11\Volume_1
5. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Dec 2012
Posts
5
Rep Power
0
Thanks for that
As you can see, I am only just starting with Python
I wanted to map a drive, to keep any python related stuff and though I would use python to do so