Slow to unmap network drive letter

96 Views Asked by At

When I try to unmap network drive letter mappings using WNetCancelConnection2 (or the depreciated WNetCancelConnection), the thread will block for about 10 seconds before the drive letter is actually unmapped if the file server is unavailable on the network. Is there a faster way to unmap this drive letter if the file server is not (and will not be) available?

1

There are 1 best solutions below

0
Olaf Hess On

Set the third parameter fForce passed to WNetCancelConnection2 to true. This should immediately terminate the connection. Please be aware that if there are open files or jobs on the connection you might loose data. So it might be a good idea to use a PING or some other means to establish whether the remote computer in online or not.