I have a file called startup.cmd in my Windows 10 startup directory called C:\Users\myuserid\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup. The contents of the file are:
@echo off
echo Now mounting your disk drives
net use h: \\celerra03\exelhome\rbaumann /persistent:yes
net use s: \\celerra03\sas\stat /persistent:yes
net use Z: \\fsmain\userdata_home /persistent:yes
echo Done mounting your disk drives
timeout 5
I use MobaXTerm to connect to this PC from another Windows 10 PC using Remote Desktop Protocol. Whenever I log into the target PC I see the messages that are displayed by the echo instruction, so I know that the startup.cmd file is being found and executed. However, for every NET USE instruction, Windows responds with a message saying error 85: the device is already in use. And if I open a Windows command prompt and enter one of the new Windows drive letters (followed by a colon), I see an error message indicating that the drive is not mounted. However, if I then manually submit the startup.cmd file for execution, it works fine! The specified drives are mounted and remain mounted within that Windows session. Why would the net use commands work fine when manually submitted from within a cmd console but not at login time even though the echo instructions are correctly being displayed at logon time?