1

Windows 10 is resisting configuration of drive letters by a logon script calling net use.

The script is a .bat file and has been placed variously in:

  • c:\windows\system32\grouppolicy\user\scripts\logon
  • c:\programdata\microsoft\windows\start menu\programs\startup

The script fails in both cases:

  • after reboot and logon;
  • if run manually from their locations (whether at the command line or by double-click).

The script has several lines in the form of:

net use l:\ \\servername\data /persistent:no

When the script is run manually from the command line in a non-elevated command prompt, each line of the script throws the error:

System error 67 has occurred.
The network name cannot be found.

Nevertheless, each such line succeeds when manually run immediately thereafter in the same directory.

The question is how to get Windows to observe the script's configuration. Any constructive input would be much appreciated.

ebsf
  • 155
  • 7

1 Answers1

1

I duplicated your error, and it comes from incorrect syntax in the command. I don't really understand why it works for you from the command prompt, since it didn't work for me.

The correct syntax is :

net use l: \\servername\data /persistent:no

The backslash after the drive-letter should be omitted.

harrymc
  • 455,459
  • 31
  • 526
  • 924
  • That's subtle. Thanks. The remaining issue is that the revised script succeeds if run manually but does not execute from c:\windows\system32\grouppolicy\user\scripts\logon. The \scripts directory and its \logon and \logoff subdirectories didn't exist at first, so I created them. Do you know why this script would fail to execute, and which alternative locations might you suggest (beyond the \Start Menu\Programs\Startup instances for the system and user, that is)? – ebsf Feb 02 '23 at 17:26
  • Also, I probably didn't notice having the drive letter's trailing backslash in the script, and when typing them manually probably omitted it without realizing. – ebsf Feb 02 '23 at 17:30
  • The script perhaps needs a delay for the login environment to stabilize before it runs. Try adding a [timeout command](https://ss64.com/nt/timeout.html) at its beginning. – harrymc Feb 02 '23 at 20:37
  • No go. Unless timeout is case-sensitive, 20 seconds doesn't do it. I'll try moving the file to one of the \Startup directories and report back. LMK in the meantime if you have any thoughts. Maybe having to create the directories means the system isn't looking there. – ebsf Feb 02 '23 at 21:53
  • The script succeeds in the system's \Startup folder but again, not in the \Logon folder. It's odd that the latter didn't exist and perhaps that accounts for the system's configuration resistance to scripts located there. Just another Microsoft Moment (R). – ebsf Feb 03 '23 at 00:17