[Tutor] python win32 drive mapping help

Dave Angel davea at dejaviewphoto.com
Tue Sep 22 17:56:06 CEST 2009


Vineet Kothari wrote:
> Hi Everyone
>
> I saw alot of responses for python on this <http://python.org> mailing list.
> I thought any python guru might wish to help me with little code to map two
> network drives on windows systems
>
>
> I have 3computers at different locations in a network A,B,C
>
> I want to map c:/temp folder of A to C & c:/temp folder of B to C as well do
> some copying of data and then delete the mapping.
>
> I tried using the code given for mapping:
>
> import win32net
>   
>> win32net.NetUseAdd(None,1,{'remote':r'\\server\share','local':'K:','password':'XXX'
>> })
>>
>>     
>
> but I get this error:
>
> C:\Users\Administrator\Desktop>python test.py
>   
>> Traceback (most recent call last):
>>   File "test.py", line 31, in <module>
>>     import win32wnet
>> ImportError: No module named win32net
>>
>>     
>
> I just need help in setting up the mapping. I know how to do the copying
> using shutil please if you can help me with the mapping code. I am very new
> to python and I need this help for my project at school.
>
> I am using python 2.6
>
> I'll be eagerly waiting for your response.
> Thanks
>
>   
As someone else pointed out, you need to make sure you have the win32 
extensions installed.  A quick manual check would be to look in the 
install directory for the win32 files, something like:

     python26\lib\site-packages\win32\win32net.pyd

But I'd point out an essential problem in your message:  your error 
message isn't self-consistent, indicating to me that perhaps you retyped 
it in the message.  It's important to use copy/paste to get the program 
samples and error messages precise;  tiny typos can sometimes change the 
diagnosis significantly.

You can do copy/paste from a console window, for example by enabling 
quick-edit mode.  You turn that on by doing right click on the title bar 
and choosing properties.  Once quick-edit is on, you can select any 
rectangle from a console window, and copy it to clipboard with right-click.

DaveA




More information about the Tutor mailing list