To allow sharing – mapping network
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters\AllowInsecureGuestAuth -> set to 1
To disable autoconnect – mapping network
- run cmd as administrator
- type – net service server /autodisconnect:-1 (-1 means disable)
- else set to minutes – net service server /autodisconnect: timeout minutes
or set in regedit Lanman -> parameters to ffffffff (8 f’s)
To force connect network mapping
-> refer: http://woshub.com/could-not-reconnect-mapped-network-drives/
-> refer: https://docs.microsoft.com/en-us/troubleshoot/windows-client/networking/mapped-network-drive-fail-reconnect
PowerShell -Command "Set-ExecutionPolicy -Scope CurrentUser Unrestricted" >> "%TEMP%\StartupLog.txt" 2>&1
PowerShell -File "%SystemDrive%\Scripts\MapDrives.ps1" >> "%TEMP%\StartupLog.txt" 2>&1
$i=3
while($True){
$error.clear()
$MappedDrives = Get-SmbMapping |where -property Status -Value Unavailable -EQ | select LocalPath,RemotePath
foreach( $MappedDrive in $MappedDrives)
{
try {
New-SmbMapping -LocalPath $MappedDrive.LocalPath -RemotePath $MappedDrive.RemotePath -Persistent $True
} catch {
Write-Host "There was an error mapping $MappedDrive.RemotePath to $MappedDrive.LocalPath"
}
}
$i = $i - 1
if($error.Count -eq 0 -Or $i -eq 0) {break}
Start-Sleep -Seconds 30
}
- Copy the script file (MapDrives.cmd) to the following location:
%ProgramData%\Microsoft\Windows\Start Menu\Programs\StartUp - Copy the script file (MapDrives.ps1) to the following location:
%SystemDrive%\Scripts\ (Create a C:\Scripts folder) - A log file (StartupLog.txt) will be created in the %TEMP%\ folder.
- Log off, and then log back on to the device to open the mapped drives.