
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.
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 gpedit
tool to enable the Always wait for the network at computer startup and logon policy under Computer Configuration > Administrative Templates > System > Logon
. This had no effect on the problem.
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, C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup
. Windows runs anything it finds in this startup folder after I log in.
@echo off
echo reconnecting SMB shares
:wait4network
echo testing network connection by pinging the host
ping -n 1 fang >nul 2>&1 && (
echo network connection exists
echo making sure \\nas\storage is mounted as x:
dir x: >nul 2>&1 || net use x: \\nas\storage /user:MYID /persistent:yes MYPASSWORD >nul 2>&1
echo making sure \\fang\rootdir is mounted as z:
dir z: >nul 2>&1 || net use z: \\fang\rootdir /user:MYID /persistent:yes MYPASSWORD >nul 2>&1
) || (
echo network connection isn't working, try again
C:\Windows\System32\timeout.exe /t 5 /nobreak
goto wait4network
)
echo all done
C:\Users\MYID\reconnect_SMB_shares.bat
contains the commands needed to reconnect the SMB shares.
@echo off
REM Run by a shortcut placed in the C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup folder
cmd /c C:\Users\MYID\reconnect_SMB_shares.bat >C:\Users\MYID\reconnect_SMB_shares.log 2>&1
C:\Users\MYID\autostart.bat
is meant to be my general autostart script. It includes a call to reconnect_SMB_shares.bat
. I used File Explorer to create a shortcut for this batch file and moved that shortcut into the C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup
directory so that it runs after login. It seems to take about 60 seconds after login before the script gets called.
Notice that the output of the reconnect_SMB_shares.bat
script is written to a log file in the home directory. This gives me a way to confirm that the script actually ran.