• 搜索
  • 夜间模式
    ©2014-2025  手札 Theme by OneBlog
    搜索
    标签
  • 首页>
  • 随笔>
  • 正文
  • pc微信禁止升级

    2025年04月14日 194 阅读 0 评论 2142 字

    下面内容保存为bat文件,执行即可

    @echo off
    chcp 65001 >nul
    title 合并脚本:修改hosts及禁止PC微信自动升级
    
    :: 修改hosts文件部分
    :: 定义要修改的域名和IP地址
    set ip=127.0.0.1
    set domain1=dldir1.qq.com
    set domain2=dldir1v6.qq.com
    
    :: 备份hosts文件
    copy %systemroot%\system32\drivers\etc\hosts %systemroot%\system32\drivers\etc\hosts.bak
    
    :: 检查hosts文件中是否已存在要修改的域名记录
    findstr /C:"%domain1%" %systemroot%\system32\drivers\etc\hosts >nul
    if %errorlevel% equ 0 (
        :: 如果存在,使用REPLACE命令替换记录
        echo 正在修改 %domain1% 的记录...
        echo %ip% %domain1% > %systemroot%\system32\drivers\etc\temp.txt
        replace /A /P %systemroot%\system32\drivers\etc\temp.txt %systemroot%\system32\drivers\etc\hosts
        del %systemroot%\system32\drivers\etc\temp.txt
    ) else (
        :: 如果不存在,直接添加记录
        echo 正在添加 %domain1% 的记录...
        echo %ip% %domain1% >> %systemroot%\system32\drivers\etc\hosts
    )
    
    :: 检查并处理第二个域名
    findstr /C:"%domain2%" %systemroot%\system32\drivers\etc\hosts >nul
    if %errorlevel% equ 0 (
        echo 正在修改 %domain2% 的记录...
        echo %ip% %domain2% > %systemroot%\system32\drivers\etc\temp.txt
        replace /A /P %systemroot%\system32\drivers\etc\temp.txt %systemroot%\system32\drivers\etc\hosts
        del %systemroot%\system32\drivers\etc\temp.txt
    ) else (
        echo 正在添加 %domain2% 的记录...
        echo %ip% %domain2% >> %systemroot%\system32\drivers\etc\hosts
    )
    echo hosts文件修改完成。
    
    :: 禁止PC微信自动升级部分
    reg add "HKEY_CURRENT_USER\Software\Tencent\WeChat" /v "NeedUpdateType" /t reg_dword /d "0" /f >nul 2>nul 
    echo 步骤1完成。
    del /f /q %USERPROFILE%\AppData\Roaming\Tencent\WeChat\"All Users"\config\update.data >nul 2>nul 
    md %USERPROFILE%\AppData\Roaming\Tencent\WeChat\"All Users"\config\update.data >nul 2>nul 
    echo Y|cacls "%USERPROFILE%\AppData\Roaming\Tencent\WeChat\All Users\config\update.data" /T /P %USERNAME%:N >nul 2>nul 
    echo 步骤2完成。 
    rd /s /q %USERPROFILE%\AppData\Roaming\Tencent\WeChat\patch >nul 2>nul 
    md %USERPROFILE%\AppData\Roaming\Tencent\WeChat\patch >nul 2>nul 
    echo Y|cacls %USERPROFILE%\AppData\Roaming\Tencent\WeChat\patch /T /P %USERNAME%:N >nul 2>nul 
    echo 步骤3完成。 
    
    echo 设置完成,正在自动退出。 
    timeout /nobreak /t 2 >nul 2>nul 
    exit    
    本文著作权归作者 [ 东 ] 享有,未经作者书面授权,禁止转载,封面图片来源于 [ 互联网 ] ,本文仅供个人学习、研究和欣赏使用。如有异议,请联系博主及时处理。
    — END —
    Copyright©2014-2025  All Rights Reserved.  Load:0.011 s
    Theme by OneBlog V3.6.3
    夜间模式

    开源不易,请尊重作者版权,保留基本的版权信息。