@echo off
echo This script will help you optimize your development environment by disabling unnecessary Windows services.
echo Note: Before running this script, make sure you understand the role of each service to avoid affecting system operation.
pause
:: 确保每个服务都适用于Windows 11
:: 禁用Application Identity服务(AppIDSvc)
sc config “AppIDSvc” start= disabled
:: 禁用AppX Deployment Service(AppXSvc)
sc config “AppXSvc” start= disabled
:: 禁用Background Intelligent Transfer Service(BITS)
sc config “BITS” start= disabled
:: 禁用BitLocker Drive Encryption(BDESVC)
sc config “BDESVC” start= disabled
:: 禁用CNG Key Isolation(KeyIso)
sc config “KeyIso” start= disabled
:: 禁用COM+ Event System(EventSystem)
sc config “EventSystem” start= disabled
:: 禁用Credential Manager(VaultSvc)
sc config “VaultSvc” start= disabled
:: 禁用Device Association Service(dmwappushsvc)
sc config “dmwappushsvc” start= disabled
:: 禁用Distributed Link Tracking Client(TrkWks)
sc config “TrkWks” start= disabled
:: 禁用DNS Client(Dnscache)
sc config “Dnscache” start= disabled
:: 禁用Group Policy Client(gpsvc)
sc config “gpsvc” start= disabled
:: 禁用Print Spooler(Spooler)
sc config “Spooler” start= disabled
:: 禁用Remote Procedure Call (RPC) Locator(RpcLocator)
sc config “RpcLocator” start= disabled
:: 禁用Windows Search(SearchIndexer)
sc config “SearchIndexer” start= disabled
:: 禁用Windows Update(wuauserv)
sc config “wuauserv” start= disabled
:: 禁用WinHTTP Web Proxy Auto-Discovery Service(WinHttpAutoProxySvc)
sc config “WinHttpAutoProxySvc” start= disabled
:: 不禁用WSL Service(wslservice)因为对于某些开发者来说是必需的
rem sc config “wslservice” start= disabled
:: 禁用蓝牙音频网关服务(BluetoothUserService_###### 其中######代表用户SID)
:: 注意:在Windows 11中,蓝牙相关服务名可能包含用户SID,建议手动查找具体服务名。
sc config “BluetoothUserService” start= disabled
:: 禁用蓝牙支持服务(BthAvctpSvc)
sc config “BthAvctpSvc” start= disabled
:: 禁用连接设备平台服务(PcaSvc)
sc config “PcaSvc” start= disabled
:: 数据使用量服务在Windows 11下可能不直接对应,因此这里省略或替换为实际存在的服务
:: 迅雷下载基础服务和中国电子口岸客户端控制服务等第三方服务请根据实际情况保留或移除
sc config “ThunderDownloadBaseService” start= disabled
sc config “ChinaElectronicPortClientControl” start= disabled
:: 禁用SSDP Discovery(ssdpsvc)
sc config “ssdpsvc” start= disabled
:: State Repository Service(StateRepository)
sc config “StateRepository” start= disabled
:: Shell Hardware Detection(ShellHWDetection)
sc config “ShellHWDetection” start= disabled
:: Smart Card Removal Policy(SCardSvr)
sc config “SCardSvr” start= disabled
:: Network List Service(netprofm)
sc config “netprofm” start= disabled
:: Network Store Interface Service(Nsi)
sc config “Nsi” start= disabled
echo 服务设置已完成。请注意检查是否有任何服务被错误禁用。
pause