Python Forum

Full Version: use win32wnet to connect shared networks
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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