V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
rshun

手工用命令行启动 clash

  •  
  •   rshun · Nov 2, 2023 · 2203 views
    This topic created in 917 days ago, the information mentioned may be changed or developed.
    • 将下列内容存为 bat 文件
    • clash-windows-amd64.exe 可以放在任何地方,内容中的路径需要修改
    • 双击即可启动或关闭
    • 正常启动是最小化,如果想隐藏窗口的话,请使用管理员模式(关闭的时候也要用管理员模式)
    • 适用于 Windows
    • 如果想看日志,可以在配置文件中配置一下 external-controller,就可以用浏览器查看

    启动脚本

    @echo off 
    reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f >nul 2>nul
    reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /d "127.0.0.1:7890" /f >nul 2>nul
    cd %userprofile%\.config\clash
    powershell -WindowStyle Hidden -Command "& {C:\Tools\clash\clash-windows-amd64.exe -f config.yaml}"
    

    关闭脚本

    @echo off 
    taskkill /F /IM clash-windows-amd64.exe
    reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f >nul 2>nul
    reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /d "" /f >nul 2>nul
    
    3 replies    2023-11-03 08:42:48 +08:00
    AoEiuV020JP
        1
    AoEiuV020JP  
       Nov 2, 2023
    改注册表设置代理这个效果不大好,有可能需要重启生效,还不如手动改,或者我是用 sysproxy.exe 修改系统代理,
    rshun
        2
    rshun  
    OP
       Nov 2, 2023
    不需要重启系统,我一直都是手工启的
    SenLief
        3
    SenLief  
       Nov 3, 2023 via iPhone
    没必要吧。win 自己有启动平台的,不过我还是喜欢用 nssm 。
    sudo nssm.exe start clash
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5713 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 44ms · UTC 06:55 · PVG 14:55 · LAX 23:55 · JFK 02:55
    ♥ Do have faith in what you're doing.