With the new Windows 1909 update we got some nice fixes of crucial issues with Windows 10, but also got a few new bugs. For me, probably the most annoying one is that with every boot all of my 20 network drives are marked as offline. Now the fix is easy, just pop them open with your explorer, and the notification (could not reconnect all network drives) goes away, but doing that for all of them is a bit annoying. Now Microsoft is aware of the issue and has marked it to be fixed within the next updates, but until then here is a small script that will find and open (as well as close) those drives for you and make the notification go away.

Just save the bellow script as ANYTHING.bat save it to your PC and either add it to your startup menu or just leave it on your desktop to click when you need to.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
@echo off
setlocal enabledelayedexpansion
echo Auto reconnect all offline network drives
echo Slurp-Ramen.com April 2020
echo https://slurp-ramen.com
 
echo .
echo Waiting for your network
set LC=0
goto :waitfornet_
:waitfornet
    timeout /t 1 /NOBREAK >nul
:waitfornet_
    route print -4  | findstr /C:" 0.0.0.0 " >nul 2>nul
    if not errorlevel 1 goto :NetReady
    set /A LC=%LC%+1
if %LC% LSS 30 goto :waitfornet
goto :eof
 
:NetReady
echo .
echo Network online
timeout /t 5 /nobreak >nul
goto :RefreshNetDrives
 
:RefreshNetDrives
echo .
echo Searching for offline drives:
 
set "OfflineNetDrives_cnt=0"
 
net use | findstr /b /v OK |findstr "A:"
if not errorlevel 1 (
    set /a OfflineNetDrives_cnt+=1
    set "OfflineNetDrives[!OfflineNetDrives_cnt!]=A:"
)
net use | findstr /b /v OK |findstr "B:"
if not errorlevel 1 (
    set /a OfflineNetDrives_cnt+=1
    set "OfflineNetDrives[!OfflineNetDrives_cnt!]=B:"
)
net use | findstr /b /v OK |findstr "C:"
if not errorlevel 1 (
    set /a OfflineNetDrives_cnt+=1
    set "OfflineNetDrives[!OfflineNetDrives_cnt!]=C:"
)
net use | findstr /b /v OK |findstr "D:"
if not errorlevel 1 (
    set /a OfflineNetDrives_cnt+=1
    set "OfflineNetDrives[!OfflineNetDrives_cnt!]=D:"
)
net use | findstr /b /v OK |findstr "E:"
if not errorlevel 1 (
    set /a OfflineNetDrives_cnt+=1
    set "OfflineNetDrives[!OfflineNetDrives_cnt!]=E:"
)
net use | findstr /b /v OK |findstr "F:"
if not errorlevel 1 (
    set /a OfflineNetDrives_cnt+=1
    set "OfflineNetDrives[!OfflineNetDrives_cnt!]=F:"
)
net use | findstr /b /v OK |findstr "G:"
if not errorlevel 1 (
    set /a OfflineNetDrives_cnt+=1
    set "OfflineNetDrives[!OfflineNetDrives_cnt!]=G:"
)
net use | findstr /b /v OK |findstr "H:"
if not errorlevel 1 (
    set /a OfflineNetDrives_cnt+=1
    set "OfflineNetDrives[!OfflineNetDrives_cnt!]=H:"
)
net use | findstr /b /v OK |findstr "I:"
if not errorlevel 1 (
    set /a OfflineNetDrives_cnt+=1
    set "OfflineNetDrives[!OfflineNetDrives_cnt!]=I:"
)
net use | findstr /b /v OK |findstr "J:"
if not errorlevel 1 (
    set /a OfflineNetDrives_cnt+=1
    set "OfflineNetDrives[!OfflineNetDrives_cnt!]=J:"
)
net use | findstr /b /v OK |findstr "K:"
if not errorlevel 1 (
    set /a OfflineNetDrives_cnt+=1
    set "OfflineNetDrives[!OfflineNetDrives_cnt!]=K:"
)
net use | findstr /b /v OK |findstr "L:"
if not errorlevel 1 (
    set /a OfflineNetDrives_cnt+=1
    set "OfflineNetDrives[!OfflineNetDrives_cnt!]=L:"
)
net use | findstr /b /v OK |findstr "M:"
if not errorlevel 1 (
    set /a OfflineNetDrives_cnt+=1
    set "OfflineNetDrives[!OfflineNetDrives_cnt!]=M:"
)
net use | findstr /b /v OK |findstr "N:"
if not errorlevel 1 (
    set /a OfflineNetDrives_cnt+=1
    set "OfflineNetDrives[!OfflineNetDrives_cnt!]=N:"
)
net use | findstr /b /v OK |findstr "O:"
if not errorlevel 1 (
    set /a OfflineNetDrives_cnt+=1
    set "OfflineNetDrives[!OfflineNetDrives_cnt!]=O:"
)
net use | findstr /b /v OK |findstr "P:"
if not errorlevel 1 (
    set /a OfflineNetDrives_cnt+=1
    set "OfflineNetDrives[!OfflineNetDrives_cnt!]=P:"
)
net use | findstr /b /v OK |findstr "Q:"
if not errorlevel 1 (
    set /a OfflineNetDrives_cnt+=1
    set "OfflineNetDrives[!OfflineNetDrives_cnt!]=Q:"
)
net use | findstr /b /v OK |findstr "R:"
if not errorlevel 1 (
    set /a OfflineNetDrives_cnt+=1
    set "OfflineNetDrives[!OfflineNetDrives_cnt!]=R:"
)
net use | findstr /b /v OK |findstr "S:"
if not errorlevel 1 (
    set /a OfflineNetDrives_cnt+=1
    set "OfflineNetDrives[!OfflineNetDrives_cnt!]=S:"
)
net use | findstr /b /v OK |findstr "T:"
if not errorlevel 1 (
    set /a OfflineNetDrives_cnt+=1
    set "OfflineNetDrives[!OfflineNetDrives_cnt!]=T:"
)
net use | findstr /b /v OK |findstr "U:"
if not errorlevel 1 (
    set /a OfflineNetDrives_cnt+=1
    set "OfflineNetDrives[!OfflineNetDrives_cnt!]=U:"
)
net use | findstr /b /v OK |findstr "V:"
if not errorlevel 1 (
    set /a OfflineNetDrives_cnt+=1
    set "OfflineNetDrives[!OfflineNetDrives_cnt!]=V:"
)
net use | findstr /b /v OK |findstr "W:"
if not errorlevel 1 (
    set /a OfflineNetDrives_cnt+=1
    set "OfflineNetDrives[!OfflineNetDrives_cnt!]=W:"
)
net use | findstr /b /v OK |findstr "X:"
if not errorlevel 1 (
    set /a OfflineNetDrives_cnt+=1
    set "OfflineNetDrives[!OfflineNetDrives_cnt!]=X:"
)
net use | findstr /b /v OK |findstr "Y:"
if not errorlevel 1 (
    set /a OfflineNetDrives_cnt+=1
    set "OfflineNetDrives[!OfflineNetDrives_cnt!]=Y:"
)
net use | findstr /b /v OK |findstr "Z:"
if not errorlevel 1 (
    set /a OfflineNetDrives_cnt+=1
    set "OfflineNetDrives[!OfflineNetDrives_cnt!]=Z:"
)
 
echo !OfflineNetDrives_cnt! Found offline drives
echo .
echo Reconnecting all offline drives:
for /L %%n in (1 1 !OfflineNetDrives_cnt!) DO ( echo !OfflineNetDrives[%%n]! & Start /min explorer "!OfflineNetDrives[%%n]!")
goto :CleanUp
 
:CleanUp
timeout /t 5 /nobreak >nul
echo .
 
echo Exiting all windows opened
 
for /L %%n in (1 1 !OfflineNetDrives_cnt!) DO (
for /f "tokens=2 delims=," %%a in ('tasklist /fi "imagename eq explorer.exe" /v /fo:csv /nh ^| findstr /r "!OfflineNetDrives[%%n]!"') do (echo !OfflineNetDrives[%%n]! & taskkill /pid %%a)
)
echo .
echo Done
timeout /t 5 /nobreak >nul

Comments

  1. Fabian

    Nice Script 🙂

    One Issue i still have, the script dosent reconnect a Home Folder that is located on a Fileserver.
    How can i fix this issue? All other network drives are reconecting with your script properly. The remote home folder dosent

    thank you

  2. Denis Article Author

    Probably the “Home Folder” you are mentioning is not designated as a drive letter in this script. Just replace the findstr “Z:” and “OfflineNetDrives[!OfflineNetDrives_cnt!]=Z:” part of the script with the name of your device (the example is if it’s called Z:

    Hope it helps!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.