'Network drive after restart disconnect

I need advice. I run a script on my computer that copies the files to the network drive. Periodically, it turns on via the task scheduler. But it happens that after a reboot the network drive does not connect - even though when I set it up I checked "reconnect at login". (Usually I just double-click on the drive and it reconnects). But if I don't do this, the script can't put it anywhere because the disk doesn't seem to be there.

enter image description here

I tried:

  • turning off fast booting,

  • put a batch file in the folder after boot:

    @echo Create new Y: drive mapping
      net use Y: \\server\folder
      :exit
    
  • put another batch file in the "after boot" folder

      @echo off
    
      :Start
      timeout /t 5 /nobreak >NUL
      if exist Y:\NUL goto End
      net use Y: \\server\folder /USER:domain\user password /PERSISTENT:YES
      if ERRORLEVEL 1 goto Start
      :End
    

But neither solved the problem.



Solution 1:[1]

I had exactly this problem some days ago. The solution I used was nothing really professional, but it worked.

I just created a textfile via powershell within the networkfolder. Everytime I now restart my PC it just writes the newest date in this txt. I know its not perfect, but it works.

New-Item \\Server\Folder\RecentLogin.txt
$var_date = Get-Date
Set-Content \\Server\Folder\RecentLogin.txt "$var_date"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 SpiesserFreak