Windows XP's mapped network drives often fail to reconnect automatically at startup when the required network resources aren't immediately available. This becomes particularly problematic when accessing network shares through SSH tunnels that establish after login.
The traditional Reconnect at logon
checkbox in Windows XP only works when:
- The network location is immediately accessible at login
- The credentials are properly cached
- The network interface is fully initialized
When dealing with SSH-tunneled connections that establish post-login, we need a more robust solution.
Create a batch file (reconnect_drives.bat
) to run after your SSH tunnel establishes:
@echo off
:RETRY
timeout /t 5 > nul
net use Y: \\server\share /persistent:yes
if errorlevel 1 goto RETRY
net use Z: \\server2\share2 /persistent:yes
if errorlevel 1 goto RETRY
If you're using PuTTY for SSH tunneling, modify your connection settings:
- In PuTTY configuration, go to Connection → SSH
- Under "Remote command", enter the path to your batch file
- Alternatively, add the batch file to your Startup folder
For more sophisticated control, use this PowerShell script (DriveReconnect.ps1
):
do {
try {
New-PSDrive -Name "Y" -PSProvider FileSystem -Root "\\server\share" -Persist
New-PSDrive -Name "Z" -PSProvider FileSystem -Root "\\server2\share2" -Persist
$connected = $true
}
catch {
Start-Sleep -Seconds 10
$connected = $false
}
} while (-not $connected)
Create a scheduled task that triggers:
- At system startup (with delay)
- On network connection events
- After user login
Configure it to run either the batch file or PowerShell script.
For applications like OneNote that need immediate access:
// C# example to force drive reconnection
try {
Directory.GetFiles(@"Y:\");
} catch {
// Trigger reconnection logic
System.Diagnostics.Process.Start("reconnect_drives.bat");
}
Modify these registry keys for more aggressive reconnection attempts:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanworkstation\parameters]
"EnablePlainTextPassword"=dword:00000001
"ConnectionCount"=dword:00000010
"KeepConn"=dword:00002710
Managing network drives in Windows XP becomes particularly tricky when those drives depend on SSH tunnel availability. The classic "Reconnect at logon" checkbox often fails because:
- Network paths become accessible only after tunnel establishment
- Applications attempt access before tunnel initialization
- Windows doesn't automatically retry failed connections
We'll implement a two-pronged approach:
- Trigger drive reconnection after tunnel establishment
- Build application-level resilience for drive access attempts
Create a batch script (reconnect_drives.bat
) to force reconnection:
@echo off :: Wait for tunnel to become active ping -n 30 127.0.0.1 > nul :: Reconnect all drives net use Y: \\server\share /persistent:yes net use Z: \\server2\share2 /persistent:yes :: Verify connections net use > C:\drive_connections.log
Make this script run automatically when your SSH tunnel establishes by adding it to your SSH client's post-connection commands or Windows Scheduled Tasks.
For applications like OneNote, we can implement a wrapper script to ensure drive availability:
:: onenote_launcher.bat @echo off :retry if exist Y:\ ( start "" "C:\Program Files\Microsoft Office\ONENOTE.EXE" ) else ( net use Y: \\server\share /persistent:yes timeout /t 5 goto retry )
For more robust handling, consider this PowerShell script:
# drive_reconnector.ps1 $drives = @{ "Y" = "\\server\share" "Z" = "\\server2\share2" } foreach ($drive in $drives.GetEnumerator()) { if (-not (Test-Path "$($drive.Key):\")) { try { New-PSDrive -Name $drive.Key -PSProvider FileSystem -Root $drive.Value -Persist -ErrorAction Stop Write-Host "Successfully connected $($drive.Key): drive" } catch { Write-Warning "Failed to connect $($drive.Key): - $_" } } }
Add these registry tweaks to improve reconnection behavior:
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanworkstation\parameters] "DeferredDelayedAckThreshold"=dword:00000001 "EnablePlainTextPassword"=dword:00000001
Implement logging to track connection attempts:
:: Add to your batch scripts echo %date% %time% - Attempting drive reconnection >> C:\drive_connection.log net use >> C:\drive_connection.log