NET USE in a batch file- sometimes works


  1. Posts : 55
    Windows 10 Anniversary (Pro)
       #1

    NET USE in a batch file- sometimes works


    Windows 10 Pro
    I have a batch file where I map my net devices, mostly Samba shares from my Linux servers.
    (I know you don't like to see snippets, but the bat file is over 300 lines long.)
    Basically, I have a function for each drive to be mounted:
    Code:
    :mntXrem Shared folder on NUCIF EXIST "x:\" goto xXnet use x: \\nuc4\hshare /user:nuc raspberry /yIF %ERRORLEVEL% EQU 0 goto xXrem Try deleting the map and try againnet use x: /d /y >NULnet use x: \\nuc4\share /user:nuc raspberry /ysleep 1s:xXgoto:eof
    At least one of the drives, seemingly at random, will give me a "name not found" error or a "System Error 5" (AKA. BSOD for NET), but when I open a CMD window and manually enter the net use line, it works. Sometimes simply repeating the bat file corrects the problem.

    Can anyone suggest why running the net use from a bat file could fail when the same net use in a cmd window connects just fine?

    <And how do I properly post code?>
      My Computer


  2. Posts : 8,171
    windows 10
       #2

    The fool proof way is to use IP not name you would have to set static IP or reserve it on the router or you could put the name in the host file. The problem is name resolution
      My Computer


  3. Posts : 55
    Windows 10 Anniversary (Pro)
    Thread Starter
       #3

    Samuria said:
    The fool proof way is to use IP not name you would have to set static IP or reserve it on the router or you could put the name in the host file. The problem is name resolution
    Thanks.
    Windows won't let me use the same IP for different shares. I forget the exact error. I fix this with multiple names in my hosts file:

    192.168.1.54 nuc1
    192.168.1.54 nuc2
    192.168.1.54 nuc3
    192.168.1.54 nuc4
    192.168.1.54 nuc5
    192.168.1.54 nuc6
    192.168.1.54 nuc7
    192.168.1.54 nuc8
    192.168.1.54 nuc9

    Each name is only used once.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 04:28.
Find Us




Windows 10 Forums