firefox proxy settings via command line

后端 未结 19 1702
闹比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:03

    You can easily launch Firefox from the command line with a proxy server using the -proxy-server option.

    This works on Mac, Windows and Linux.

    path_to_firefox/firefox.exe -proxy-server %proxy_URL%

    Mac Example:

    /Applications/Firefox.app/Contents/MacOS/firefox -proxy-server proxy.example.com

    0 讨论(0)
  • 2020-12-02 19:05

    Firefox? I don't think you can. IE is another story though..

    0 讨论(0)
  • 2020-12-02 19:08
    @echo off
    color 1F
    
    
    cd /D "%APPDATA%\Mozilla\Firefox\Profiles"
    cd *.default 
    set ffile=%cd%
    cd %ffile%
    echo user_pref("network.proxy.http", "192.168.1.235 ");>>"prefs.js" 
    echo user_pref("network.proxy.http_port", 80);>>"prefs.js" 
    echo user_pref("network.proxy.type", 1);>>"prefs.js" 
    set ffile=
    cd %windir%
    
    0 讨论(0)
  • 2020-12-02 19:09

    You could also use this Powershell script I wrote to do just this, and all other Firefox settings as well.

    https://bitbucket.org/remyservices/powershell-firefoxpref/wiki/Home

    Using this you could easily manage Firefox using computer startup and user logon scripts. See the wiki page for directions on how to use it.

    0 讨论(0)
  • 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...

    0 讨论(0)
  • 2020-12-02 19:10

    This is the final compiled solution which worked for me... Tried and tested...

    Steps to Change Proxy settings in Mozilla Firefox via cmd in Windows

    1. cd /D "%APPDATA%\Mozilla\Firefox\Profiles"
    2. cd *.default

    To Replace Already Present Proxy Settings with User-defined ones

    1. powershell -Command "(gc prefs.js) -replace 'user_pref(\"network.proxy.http\", \"already present IP\")\;', 'user_pref(\"network.proxy.http\", \"your http proxy ip\");' | Set-Content prefs.js"
    2. powershell -Command "(gc prefs.js) -replace 'user_pref(\"network.proxy.http_port\", already present port)\;', 'user_pref(\"network.proxy.http_port\", your http proxy port);' | Set-Content prefs.js"
    3. powershell -Command "(gc prefs.js) -replace 'user_pref(\"network.proxy.share_proxy_settings\", already present value)\;', 'user_pref(\"network.proxy.share_proxy_settings\", true);' | Set-Content prefs.js"
    4. powershell -Command "(gc prefs.js) -replace 'user_pref(\"network.proxy.type\", already present value)\;', 'user_pref(\"network.proxy.type\", 1);' | Set-Content prefs.js"

      0 - No Proxy

      1 - Manual Proxy Configuration

      4 - Auto detect Proxy Settings

      5 - Use System Settings(default)

    5. cd %windir%

    To Check Already Present Proxy Settings

    1. cd C:\Users\{username}\AppData\Roaming\Mozilla\Firefox\Profiles\sat2m7dr.default\
    2. find /i "network.proxy" prefs.js

    To Start Firefox from CMD using your defined proxy settings

    1. cd C:\Program Files\
    2. cd "Mozilla Firefox"
    3. firefox.exe -ProfileManager
    4. Select default from the list (default-release is selected by default) and click ok.

    NOTE: You may not have to run step 14 again. Instead you can directly run firefox.exe

    0 讨论(0)
提交回复
热议问题