通过命令行设置代理(Windows) [英] Set proxies via command line (windows)

查看:360
本文介绍了通过命令行设置代理(Windows)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过自动执行此操作的命令行或脚本为我在waterfox中拥有的每个配置文件设置代理.顺便说一下,我有50个个人资料.

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.

这是我想要做的,但要通过cmd-line:

This what I want to do but via cmd-line:

推荐答案

我不知道waterfox,但如果它类似于firefox,则prefs.js的第一行状态为:

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.

我建议您制作prefs.js和user.js的备份副本 手动更改条目,并将当前文件与备份进行比较.

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.

为此使用fc.exe或更可取的winmerge.exe. 将检测到的更改应用于其他配置文件.

Use fc.exe or more comfartably winmerge.exe for this. Apply the detected changes to the other profiles.

用于备份pref.js,删除代理设置并应用您自己的示例批处理.
未经测试,使用后果自负.

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

这篇关于通过命令行设置代理(Windows)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆