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.

  • Which version of Windows is this? – Mark Henderson May 3 '17 at 12:49
  • Windows 10 Pro. I'll edit my post. – Edwardo May 3 '17 at 12:57
  • Does the command net use * /delete /y complete successfully before the mapping of the network drives fail with error code 1219? After deleting the network connections, does the net use command still shows any entries? Have you tried to run the command cmdkey.exe /delete:srv002 after deleting the network connections? As a workaround, you could also try to map the network drives by using hostnames (either NetBIOS or FQDN) instead of IP addresses when the initial net use x: \\%ipaddr%... commands fail with error code 1219. – treintje May 27 '17 at 14:49
  • 1
    Yes the command completes successfully. If I just run the part of my scripts that removes all network shares and then use the net use command to check if there are any shares it shows me no results. If I then try to configure a share using the command line it fails (1219), but using the GUI to set it up does work. – Edwardo May 29 '17 at 7:46
  • This behavior is by design? – JosefZ Jun 29 '17 at 14:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.