Vineet Kothari wrote:
Can you also help me out with the way to delete the mapped drive I know in
command line it is
net use [DRIVE:] /delete
but I am unable to figure out how I can do it from python
Since I am trying to make sure that the drive name I am giving in my code:
import win32net
win32net.NetUseAdd(None,1,{'remote':r'\\server\share','local':'K:','password':'XXX'
})
K: drive should not exist already & if it does then the mapping should be
removed first & then a new mapping should be established.
So it should be going something like:
if [mapping already exists]:
[delete mapping]
else:
[create new mapping]
Thank You everyone for the help :)
To remove a connection made with win32net.NetUseAdd(), use
win32net.NetUseDel()
Rather than bother to checking if the mapping already exists, try to
delete it, and probably ignore any exceptions.
Note that the same drive letter may be in use for some other (even
temporary) purpose, such as a USB drive, or SUBST. So if after the
NetUseDel, the NetUseAdd (also) fails, you may have one of those conditions.
DaveA
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor