Hi all,

I'm trying to connect to a Windows share using pywin32 extensions, specifically win32wnet.WNetAddConnection2 (documentation here: http://timgolden.me.uk/pywin32-docs/...ion2_meth.html .

The code I'm trying is this:

Code:
from win32wnet import WNetAddConnection2, NETRESOURCE 
resource = NETRESOURCE() 
resource.lpRemoteName = r'\\172.39.35.6\c$' 
username='bobthefisherman' 
password='thepassword' 
res = WNetAddConnection2(resource, Password=password, UserName=username) 
print res
However before I get that far it errors:

C:\Users\Morrolan\Desktop>python test.py
Traceback (most recent call last):
File "test.py", line 9, in <module>
res = WNetAddConnection2(resource, Password=password, UserName=username) pywintypes.error: (1219, 'WNetAddConnection2', 'Multiple connections to a server or shared resource by the same user, using more than one user name, are not allowed. Disconnect all previous connections to the server or shared resource and try again.')
C:\Users\Morrolan\Desktop>
However, I don't currently have a connection to this server, and I don't have a mapped drive to this server. However if I simply type that path into Explorer in Windows, I'm prompted to login (using the credentials above) and then I can browse and edit files and folders without issue.

I've tried googling but everything I can find is people asking for help, rather than solutions. Any help or assistance would be greatly appreciated.

Many Thanks in advance,
Morrolan