Skip to content

Instantly share code, notes, and snippets.

@Gesugao-san
Last active February 12, 2023 17:23
Show Gist options
  • Save Gesugao-san/fc6f75ce1923438157f4f589f47ef019 to your computer and use it in GitHub Desktop.
Save Gesugao-san/fc6f75ce1923438157f4f589f47ef019 to your computer and use it in GitHub Desktop.
Reset winsock and smb v1 and v2
@REM Microsoft Windows [Version 10.0.19045.2546]
@CD /d C:\
@SETLOCAL ENABLEDELAYEDEXPANSION
@ECHO OFF
Dism /online /Get-Features /format:table | find "SMB1Protocol"
SET Arr[0]=SMB1Protocol
SET Arr[1]=SMB1Protocol-Client
SET Arr[2]=SMB1Protocol-Server
SET Arr[3]=SMB1Protocol-Deprecation
SET Arr[4]=SMB2Protocol
SET Arr[5]=SMB2Protocol-Client
SET Arr[6]=SMB2Protocol-Server
SET Arr[7]=SMB2Protocol-Deprecation
SET "x=0"
:SymLoop
IF DEFINED Arr[%x%] (
CALL ECHO Enabling "%%Arr[%x%]%%"...
DISM /Online /Enable-Feature /All /FeatureName:"%%Arr[%x%]%%"
SET /a "x+=1"
GOTO :SymLoop
)
@REM reg add HKLM\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters /v AllowInsecureGuestAuth /t reg_dword /d 00000001 /f
netsh winsock reset
netsh int ip reset
ipconfig /release
ipconfig /renew
ipconfig /flushdns
PAUSE
EXIT /B 0
@REM https://winitpro.ru/index.php/2018/05/16/0x80070035-ne-najden-setevoj-put-windows-10/
@REM https://learn.microsoft.com/ru-ru/windows-server/storage/file-server/troubleshoot/detect-enable-and-disable-smbv1-v2-v3?tabs=server
@REM PowerShell 7.3.2
@CD /d C:\
@SETLOCAL ENABLEDELAYEDEXPANSION
Get-SmbServerConfiguration | select "*enablesmb*"
Get-WindowsOptionalFeature -Online -FeatureName SMB1Protocol
Get-WindowsOptionalFeature -Online -FeatureName SMB2Protocol
Get-SmbServerConfiguration | Select EnableSMB1Protocol
Get-SmbServerConfiguration | Select EnableSMB2Protocol
Get-Item HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters | ForEach-Object {Get-ItemProperty $_.pspath}
Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters | ForEach-Object {Get-ItemProperty $_.pspath}
Enable-WindowsOptionalFeature -Online -FeatureName SMB1Protocol
Enable-WindowsOptionalFeature -Online -FeatureName SMB1Protocol-Client
Enable-WindowsOptionalFeature -Online -FeatureName SMB1Protocol-Server
Enable-WindowsOptionalFeature -Online -FeatureName SMB1Protocol-Deprecation
Enable-WindowsOptionalFeature -Online -FeatureName SMB2Protocol
Enable-WindowsOptionalFeature -Online -FeatureName SMB2Protocol-Client
Enable-WindowsOptionalFeature -Online -FeatureName SMB2Protocol-Server
Enable-WindowsOptionalFeature -Online -FeatureName SMB2Protocol-Deprecation
Set-SmbServerConfiguration -EnableSMB1Protocol $true
Set-SmbServerConfiguration -EnableSMB2Protocol $true
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" SMB1 -Type DWORD -Value 1 -Force
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" SMB2 -Type DWORD -Value 1 -Force
@REM reg add HKLM\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters /v AllowInsecureGuestAuth /t reg_dword /d 00000001 /f
netsh winsock reset
netsh int ip reset
ipconfig /release
ipconfig /renew
ipconfig /flushdns
PAUSE
EXIT /B 0
@REM https://winitpro.ru/index.php/2018/05/16/0x80070035-ne-najden-setevoj-put-windows-10/
@REM https://learn.microsoft.com/ru-ru/windows-server/storage/file-server/troubleshoot/detect-enable-and-disable-smbv1-v2-v3?tabs=server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment