PC's in our organisation run Windows 10 Pro and are sometimes shared between users (local accounts, no domain and AD).
I have written a batch script that users execute when mounting our network shares to a drive letter. Most of the time it runs fine, but seemingly randomly it returns error 1219.
The first part of the script clears the network shares before mounting them again (so another user can logon).
NET USE * /delete /y >NUL: 2>&1
This works fine and afterwards the net use command tells me there are no more connections.
I ran into the problem of cached user credentials a while ago so I decided to add the following lines to remove the stored credentials as well.
CMDKEY /delete:Domain:target=%ipaddr% >NUL 2>&1 CMDKEY /delete:LegacyGeneric:target=%ipaddr% >NUL 2>&1
This also works fine and removes the credentials that windows stores for our fileserver.
The last part of the scripts mounts the network shares using the credentials the user provided.
NET USE H: \\%ipaddr%\home /user:srv002\%username% %password% /P:Yes NET USE P: \\%ipaddr%\Privacy /user:srv002\%username% %password% /P:Yes >NUL 2>&1 NET USE M: \\%ipaddr%\Marketing /user:srv002\%username% %password% /P:Yes >NUL 2>&1
These last lines return the error code 1219 from time to time telling me that there should not be multiple sessions using different credentials to the same server. A reboot or manually adding the shares usually works in this case.
I think I must be missing something but after some research the only solution given is to execute
NET USE * /delete /y which I already am.