Back to Blog
Mapping synology drive using netdrive 36/12/2023 #Could not UN-MAP, this might be a physical drive #Execute 'NET USE' command without authentication, incase session already open If string.find(str(cmdOutPut), 'successfully',) = -1: #Execute 'NET USE' command with authentication WinCMD2 = winCMD1 + ' ' + password + ' /User' + user WinCMD1 = 'NET USE ' + drive + ' ' + networkPath Print "Path not accessible: ", networkPath =Check the white spaces from here, these were a part of a function= def mapNetworkDrive(self, drive, networkPath, user, password): Return string.find(str(cmdOutPut), 'DIR',) #Small function to check if the mention location is a directory Return string.find(str(cmdOutPut), 'YES',) WinCMD = 'IF EXIST ' + path + ' echo YES'ĬmdOutPut = subprocess.Popen(winCMD, stdout=subprocess.PIPE, shell=True).communicate() #Small function to check the availability of network resource. Win32wnet.WNetCancelConnection2(drive, 1, force)Īssuming that you import necessary libraries, This was a part of an RPC server where the client requested the server to map a drive locally. Win32wnet.WNetAddConnection2(win32netcon.RESOURCETYPE_DISK, drive, networkPath, None, user, password)Īnd to unmap, just use. Print "Trying to map ", networkPath, " on to ", drive, ". Print drive, "Unmap failed, This might not be a network drive." Win32wnet.WNetCancelConnection2(drive, 1, 1) Print drive, " Drive in use, trying to unmap." def mapDrive(drive, networkPath, user, password, force=0): This one was after going through win32wnet.
0 Comments
Read More
Leave a Reply. |