@echo off
chcp 65001 >nul
setlocal EnableDelayedExpansion
:: ====== 自检管理员权限,非管理员则自动提权 ======
net session >nul 2>&1
if %errorlevel% neq 0 (
echo 正在请求管理员权限...
powershell -NoProfile -Command "Start-Process -FilePath '%~f0' -Verb RunAs"
exit /b
)
echo ==========================================================
echo 1/3 启用不安全的 Guest 登录 (Enable insecure guest logons)
echo ==========================================================
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\LanmanWorkstation" /v AllowInsecureGuestAuth /t REG_DWORD /d 1 /f
echo.
echo ==========================================================
echo 2/3 启用 Windows 功能 SMB 1.0
echo ==========================================================
dism /online /enable-feature /featurename:SMB1Protocol /all /norestart
echo.
echo ==========================================================
echo 3/3 禁用 SMB 通信数字签名
echo ==========================================================
echo [客户端] 数字签名通信(始终)
reg add "HKLM\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters" /v RequireSecuritySignature /t REG_DWORD /d 0 /f
echo [客户端] 数字签名通信(如果服务器同意)
reg add "HKLM\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters" /v EnableSecuritySignature /t REG_DWORD /d 0 /f
echo [服务器] 数字签名通信(始终)
reg add "HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" /v RequireSecuritySignature /t REG_DWORD /d 0 /f
echo [服务器] 数字签名通信(如果客户端同意)
reg add "HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" /v EnableSecuritySignature /t REG_DWORD /d 0 /f
echo.
echo ==========================================================
echo 刷新组策略并重启 SMB 相关服务
echo ==========================================================
gpupdate /target:computer /force
net stop LanmanWorkstation /y >nul 2>&1
net stop LanmanServer /y >nul 2>&1
net start LanmanServer >nul 2>&1
net start LanmanWorkstation >nul 2>&1
echo.
echo 全部完成!建议重启计算机使 SMB 1.0 生效。
echo ==========================================================
pause