Python Forum
use win32wnet to connect shared networks - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: use win32wnet to connect shared networks (/thread-7123.html)



use win32wnet to connect shared networks - JoanAzpeitia - Dec-21-2017

Hi guys,

Using windows, I am trying to use win32wnet module to connect a shared network through a .py file. However, I am not being able to make it work. Has someone used that module to connect shared networks successfully and can point me out on how to do it?
The line not working is the one below the try statement.
Many thanks in advance,

Joan

import os
import win32netcon
import win32wnet


ynetworkPath = '\\\\LAMPSERVER_RB\\resources_server\\'
znetworkPath = '\\\\LAMPSERVER\\lampserver\\_PROJECTS\\'
yDrive = 'Y:'
user = 'a'
password = 'b'

if (os.path.exists(ynetworkPath)):
    try:
        win32wnet.WNetAddConnection2(win32netcon.RESOURCETYPE_DISK, yDrive, ynetworkPath, None, user, password, 0)
        print "connection working"
    except:
        print "Not working"

else:
    print "path not existing"


C:\Python27\python.exe D:/pipeline/development/testing_for_network_link.py
Not working

Process finished with exit code 0