1

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?

2
  • Have you tried deleting the mappings before (re)assigning them?
    – Zac67
    Commented 11 hours ago
  • You stated the answer -- the drives are not yet mounted when the batch file is being executed at startup. Either delay execution until after all are mounted, or try using the UNC path rather than a drive letter -- see service.purdue.edu/TDClient/32/Purdue/KB/ArticleDet?ID=229 Commented 10 hours ago

0

You must log in to answer this question.

Browse other questions tagged .