Can not access the network driver in windows server 2016 in the scheduling task.

jizheng zhang 0 Reputation points
2023-08-29T03:17:38.14+00:00

Dear

 I have two computers in one local network, they can visit each other using local IP address(172.200.10.196 and 172.200.10.197), the system is windows server 2016, for the easy visiting, I added network driver to 172.200.10.197 which in fact mapped to the web address \\172.200.10.196,  the network dirver is Z:, so i can visit the share folder in the server 196 just like: Z:/Config/*.csv in my script.  
Such scripts runs correctly when I loggin in the server 197, but the same scripts will report "access failed" when I put them into the scheduled task with high priority, and runs in the mid-night when I not loggin-in.

 So what shall i do to keep the netwok driver connected and accessible anytime?  Thanks a lot!.
Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,635 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Limitless Technology 44,121 Reputation points
    2023-08-29T09:35:00.29+00:00
    Hello Jizheng,
    
    Thank you for your question and for reaching out with your question today.
    
    When you're running scheduled tasks in Windows Server 2016 that involve accessing network drives, you might encounter issues with network drive mappings if they're not properly set up.  PLease try the following:
    
    1. Instead of relying on network drive mappings (such as Z:), use UNC (Universal Naming Convention) paths directly in your scripts. UNC paths are less dependent on user sessions and tend to work more reliably in non-interactive contexts.  For example, replace `Z:/Config/*.csv` with `\\172.200.10.196\Config\*.csv`.
    
    2. In the properties of the scheduled task, on the "General" tab, check the "Run with highest privileges" option.
    
    3. When you map a network drive, use the `/PERSISTENT:YES` switch to ensure that the mapping persists across reboots and non-interactive sessions. For example:
       
    net use Z: \\172.200.10.196\Config /PERSISTENT:YES
    
    4. Sometimes, network resources might not be fully available immediately after system startup. You can configure the scheduled task to have a delay in execution to give the system more time to establish network connectivity.
    
    If the reply was helpful, please don’t forget to upvote or accept as answer.
    
    
    0 comments No comments

  2. Hania Lian 11,126 Reputation points Microsoft Vendor
    2023-09-08T07:19:03.1033333+00:00

    Hi.

    Modify the registry value of EnabledLinkedConnections under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System and set it to 1. This will enable the sharing of network connections between the standard and administrator accounts.

    Best Regards,

    Hania Lian

    0 comments No comments