{"id":391,"date":"2023-11-27T10:15:35","date_gmt":"2023-11-27T15:15:35","guid":{"rendered":"https:\/\/daveking.com\/blog\/?p=391"},"modified":"2023-11-27T10:15:35","modified_gmt":"2023-11-27T15:15:35","slug":"could-not-reconnect-all-network-drives","status":"publish","type":"post","link":"https:\/\/daveking.com\/blog\/index.php\/2023\/11\/27\/could-not-reconnect-all-network-drives\/","title":{"rendered":"Could Not Reconnect All Network Drives"},"content":{"rendered":"\n<p>My Windows virtual machines all display this notification after I initially log in to them.  I finally looked up this error and worked out a fix for this.<\/p>\n\n\n\n<p>The first fix I tried, setting a system policy inside the Windows guest system to wait for network connectivity before login, did not work.  This involved using the <code>gpedit<\/code> tool to enable the <strong>Always wait for the network at computer startup and logon<\/strong> policy under <code>Computer Configuration > Administrative Templates > System > Logon<\/code>.  This had no effect on the problem.<\/p>\n\n\n\n<p>The second fix I tried, which did work, was to create a startup script on the Windows guest to remount the SMB shares.  I created two batch scripts in my home directory and put a shortcut that pointed at one of them into the system startup folder, <code>C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Startup<\/code>. Windows runs anything it finds in this startup folder after I log in.<\/p>\n\n\n\n<pre title=\"C:\\Users\\MYID\\reconnect_SMB_shares.bat\" class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">@echo off\n\necho reconnecting SMB shares\n:wait4network\necho testing network connection by pinging the host\nping -n 1 fang >nul 2>&amp;1 &amp;&amp; (\n  echo network connection exists\n  echo making sure \\\\nas\\storage is mounted as x:\n  dir x: >nul 2>&amp;1 || net use x: \\\\nas\\storage \/user:MYID \/persistent:yes MYPASSWORD >nul 2>&amp;1\n  echo making sure \\\\fang\\rootdir is mounted as z:\n  dir z: >nul 2>&amp;1 || net use z: \\\\fang\\rootdir \/user:MYID \/persistent:yes MYPASSWORD >nul 2>&amp;1\n) || (\n  echo network connection isn't working, try again\n  C:\\Windows\\System32\\timeout.exe \/t 5 \/nobreak\n  goto wait4network\n)\necho all done<\/code><\/pre>\n\n\n\n<p><code>C:\\Users\\MYID\\reconnect_SMB_shares.bat<\/code> contains the commands needed to reconnect the SMB shares.<\/p>\n\n\n\n<pre title=\"C:\\Users\\MYID\\autostart.bat\" class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">@echo off\n\nREM Run by a shortcut placed in the C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Startup folder\n\ncmd \/c C:\\Users\\MYID\\reconnect_SMB_shares.bat >C:\\Users\\MYID\\reconnect_SMB_shares.log 2>&amp;1<\/code><\/pre>\n\n\n\n<p><code>C:\\Users\\MYID\\autostart.bat<\/code> is meant to be my general autostart script.  It includes a call to <code>reconnect_SMB_shares.bat<\/code>.  I used File Explorer to create a shortcut for this batch file and moved that shortcut into the <code>C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Startup<\/code> directory so that it runs after login. It seems to take about 60 seconds after login before the script gets called.<\/p>\n\n\n\n<p>Notice that the output of the <code>reconnect_SMB_shares.bat<\/code> script is written to a log file in the home directory.  This gives me a way to confirm that the script actually ran.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How I fixed the Windows&#8217; &#8220;Could not reconnect all network drives&#8221; error<\/p>\n","protected":false},"author":1,"featured_media":396,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_editorskit_title_hidden":false,"_editorskit_reading_time":0,"_editorskit_is_block_options_detached":false,"_editorskit_block_options_position":"{}","_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[22],"tags":[],"class_list":["post-391","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howto","eq-blocks"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/daveking.com\/blog\/wp-content\/uploads\/2023\/11\/reconnect.jpg?fit=500%2C267&ssl=1","jetpack-related-posts":[],"jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/daveking.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/391","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/daveking.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/daveking.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/daveking.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/daveking.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=391"}],"version-history":[{"count":6,"href":"https:\/\/daveking.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/391\/revisions"}],"predecessor-version":[{"id":398,"href":"https:\/\/daveking.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/391\/revisions\/398"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/daveking.com\/blog\/index.php\/wp-json\/wp\/v2\/media\/396"}],"wp:attachment":[{"href":"https:\/\/daveking.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=391"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/daveking.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=391"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/daveking.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=391"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}