Communication can remain alive sometimes even more than 12 seconds. The trick is to block a failed login after deletion.
If you block bad entry, this resource will be unavailable immediately. To do this, we can use a local guest account (usually it gives the error "Login failed: account is currently disabled." And even if it is turned on, it will not have access).
Instead simply:
net use \\server /delete
We will do:
net use \\server /delete net use \\server "" /user:"Guest" net use \\server /delete 2>nul
The third line is executed only if the guest input is succedes (it uses 2> nul to redirect the error stream to the nul device to avoid displaying error messages).
This is a batch version using the "net use" command, but the same solution can be applied when using NetUseAdd and NetUseDel from netapi32.dll or WNetAddConnection and WNetCancelConnection from mpr.dll.
source share