问题
How to set proxy to each profile I have in waterfox via command line or script who do this automatically. I have 50 profiles by the way.
This what I want to do but via cmd-line:
回答1:
I don't know waterfox, but if it is similar to firefox the first lines in prefs.js state:
> pushd "%APPDATA%\Mozilla\Firefox\Profiles\*.default"
> more prefs.js
// Mozilla User Preferences
// DO NOT EDIT THIS FILE.
//
// If you make changes to this file while the application is running,
// the changes will be overwritten when the application exits.
//
// To change a preference value, you can either:
// - modify it via the UI (e.g. via about:config in the browser); or
// - set it within a user.js file in your profile.
I suggest you make a backup copy of prefs.js and user.js change the entries manually and compare the current file with the backup.
Use fc.exe or more comfartably winmerge.exe for this. Apply the detected changes to the other profiles.
A sample batch to backup pref.js, remove proxy settings and apply your own.
Untested, use at your own risk.
:: Q:\Test\2018\07\27\SO_51554221.cmd
@Echo off
PushD "%APPDATA%\Mozilla\Firefox\Profiles\*.default"
set "ffile=%cd%\prefs.js"
:: make sure firefox is **not** running
rem your code goes here
:: First save settings
Move /Y "%ffile%" >"%ffile%.bak"
:: create a copy without lines to be changed/appended
( Findstr /IBV "user_pref(.network\.proxy\." "%ffile%.bak"
echo user_pref("network.proxy.http", "213.54.64.1");
echo user_pref("network.proxy.http_port", 91);
echo user_pref("network.proxy.type", 1);
) > "%ffile%"
PopD
回答2:
I think you can find some more information on this SE site post. For reference, here is one of the most accepted answers.
Command to enable proxy usage:
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" ^
/v ProxyEnable /t REG_DWORD /d 1 /f
Command to disable proxy usage:
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" ^
/v ProxyEnable /t REG_DWORD /d 0 /f
Command to change the proxy address:
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" ^
/v ProxyServer /t REG_SZ /d proxyserveraddress:proxyport /f
I have added line continuation (^) for improved readability. Also, in this case, it is more like a per-user setting than a system-wide setting.
来源:https://stackoverflow.com/questions/51554221/set-proxies-via-command-line-windows