王新阳

wangxinyang

SMB共享被占满时可以通过重启服务快速解决

windows局域网共享,播放视频时,错误提示如下:

smb2 error No more connections can be made to this remote computer at this time because there are already as many connections as the computer can accept.

把以下内容保存到 bat 文件中,双击运行

@echo off
:: 以管理员身份运行的检查(可选,但推荐,因为管理服务通常需要管理员权限)
net session >nul 2>&1
if %errorLevel% neq 0 (
    echo 正在请求管理员权限...
    powershell -Command "Start-Process '%~f0' -Verb RunAs"
    exit /b
)

echo 正在停止 Server 服务...
:: /y 参数在某些版本的 net stop 中用于自动确认依赖服务的停止,虽然现代 Windows 中 net stop 通常不询问,但加上更保险
net stop Server /y

if errorlevel 1 (
    echo 停止服务失败或服务未运行。
) else (
    echo 服务已成功停止。
)

echo 正在启动 Server 服务...
net start Server

if errorlevel 1 (
    echo 启动服务失败。
) else (
    echo 服务已成功启动。
)

echo 操作完成。
:: pause

缩短空闲会话自动释放时间
默认Windows要等15分钟才会自动清掉空闲会话,完全跟不上你连续换视频的节奏:
按Win+R输入regedit打开注册表编辑器
定位到路径:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters
新建一个DWORD(32位)值,命名为SessTimeout,数值设为‌300‌(单位秒,也就是5分钟)
改完后再次执行前面的重启Server服务命令,让设置立刻生效

2026-11-20
2026-11-28 星期六 农历十月二十