3

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.

Edwardo
  • 31
  • 1
  • 4
  • Which version of Windows is this? – Mark Henderson May 03 '17 at 12:49
  • Windows 10 Pro. I'll edit my post. – Edwardo May 03 '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. – 303 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 07:46
  • [This behavior is by design?](http://support.microsoft.com/kb/938120) – JosefZ Jun 29 '17 at 14:07

1 Answers1

0

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