user875531
user875531

Reputation: 55

Python use of wnet_connect(host, username = None, password = None)

I am trying to make a connection to a server which is not listed in DNS its just a server with an ip.

I am getting no luck using this code:

netpath = r'\\10.5.1.22\Products'
    networkPath = netpath
    unc = ''.join(['\\\\', host])
    print unc
    try:
            win32wnet.WNetAddConnection2(0, None, unc, None, username, password)
    except Exception, err:
        if isinstance(err, win32wnet.error):
            #Disconnect previous connections if detected, and reconnect.
            if err[0] == 1219:
                win32wnet.WNetCancelConnection2(unc, 0, 0)
                return wnet_connect(host, username, password)
        raise err

is there a better way to connect in this situation I am using Python 2.7

Upvotes: 0

Views: 1223

Answers (1)

Vb407
Vb407

Reputation: 1707

Its not possible to connect to a server or any machine, If it is not in DNS.

Upvotes: 0

Related Questions