0

On my main PC I have automated script which is looking and processing data inside of a few network drives of some remote PCs. But sometimes are network drive disconnected and I need to automaticaly refresh it's state.

Scenario:
It can happen that one of the remote PC is off and then I must for another reason restart the main PC. And then after I start the main PC on a network drive icon will appear a red sign "X" which means that a network drive of the remote PC is disconnected which is still OK. But this "X" disconnected state persists on the main PC even when somebody start the remote PC. Only when I manually click with my mouse on that network drive a "X" sign disappear and my script start working.
Scenario scerenshot

Is there any way how to automatically refresh/renew network drives in some interval e.g. via task scheduler?
But not a solution like delete drive and mount it again.

I have tried some things but without success

Mike_BossO
  • 21
  • 1
  • 6

1 Answers1

0

To automatically refresh or renew network drives, see the post
Batch file for a refresh of mapped network drive?

There are several answers, and I chose this code (replace the drive-letter and network path):

@echo off
rem test driveletter before usage of net command to prevent errormessages
if exist x:\. net use x: /del /yes
if not exist x:\. net use x: \\server\share\ /persistent:yes

Store this code in a .bat file and use Task Scheduler to create a task that runs in the wanted interval.

harrymc
  • 455,459
  • 31
  • 526
  • 924
  • Yes this is common solution for this issue but not exactly what I asked. As I mentioned before: "But not a solution like delete drive and mount it again." – Mike_BossO Sep 14 '22 at 08:16
  • Try to check if doing only `net use x: \\server\share\ /persistent:yes` acts also like a refresh. – harrymc Sep 14 '22 at 08:20
  • I tried it but it doesn't work. CMD was not able to find network path. But at same time I've tried to put network path to file explorer and path was found. [Screenshot](https://i.imgur.com/hvLDwsS.png) – Mike_BossO Sep 16 '22 at 06:27
  • It seems according to your tests that delete+mount is after all the only viable solution. – harrymc Sep 16 '22 at 07:18
  • Yes I think so too. But I was hope that it can work by another way. – Mike_BossO Sep 16 '22 at 12:12