firefox proxy settings via command line

后端 未结 19 2077
闹比i
闹比i 2020-12-02 18:20

How do I change Firefox Proxy settings via command line on windows xp/2k?

Thanks

19条回答
  •  日久生厌
    2020-12-02 19:10

    Just wanted to post the code in a cleaner format... originally posted by sam3344920

    cd /D "%APPDATA%\Mozilla\Firefox\Profiles"
    cd *.default
    set ffile=%cd%
    echo user_pref("network.proxy.http", "148.233.229.235 ");>>"%ffile%\prefs.js"
    echo user_pref("network.proxy.http_port", 3128);>>"%ffile%\prefs.js"
    echo user_pref("network.proxy.type", 1);>>"%ffile%\prefs.js"
    set ffile=
    cd %windir%
    

    If someone wants to remove the proxy settings, here is some code that will do that for you.

    cd /D "%APPDATA%\Mozilla\Firefox\Profiles"
    cd *.default
    set ffile=%cd%
    type "%ffile%\prefs.js" | findstr /v "user_pref("network.proxy.type", 1);" >"%ffile%\prefs_.js"
    rename "%ffile%\prefs.js" "prefs__.js"
    rename "%ffile%\prefs_.js" "prefs.js"
    del "%ffile%\prefs__.js"
    set ffile=
    cd %windir%
    

    Explaination: The code goes and finds the perfs.js file. Then looks within it to find the line "user_pref("network.proxy.type", 1);". If it finds it, it deletes the file with the /v parameter. The reason I added the rename and delete lines is because I couldn't find a way to overwrite the file once I had removed the proxy line. I'm sure there is a more efficient/safer way of doing this...

提交回复
热议问题