Windows – Getting error 1219 while there are no other sessions

batchnet-usenetwork-sharenetworkingwindows

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.

Best Answer

I have not found a permanent solution yet, but using the same IP address for subsequent 'net use' commands is the cause of the error.

net use w: \192.168.1.54\steve

net use x: \192.168.1.54\jim

net use y: \192.168.1.54\ralph

In this example, drives X: and Y: won't mount.

My iperfect solution- I added some entries in my hosts file:

192.168.1.54 nuc

192.168.1.54 nuc1

192.168.1.54 nuc2

192.168.1.54 nuc3

192.168.1.54 nuc4

This way I can execute 'net use' commands this way without (most of the time) 1219 errors.

net use w: \nuc1\steve

net use x: \nuc2\jim

net use y: \nuc3\ralph