How do I change Firefox Proxy settings via command line on windows xp/2k?
Thanks
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
Firefox? I don't think you can. IE is another story though..
@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%
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.
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...
This is the final compiled solution which worked for me... Tried and tested...
powershell -Command "(gc prefs.js) -replace 'user_pref(\"network.proxy.type\", already present value)\;', 'user_pref(\"network.proxy.type\", 1);' | Set-Content prefs.js"
cd %windir%
NOTE: You may not have to run step 14 again. Instead you can directly run firefox.exe