Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 通过命令行(windows)设置代理_Batch File_Cmd - Fatal编程技术网

Batch file 通过命令行(windows)设置代理

Batch file 通过命令行(windows)设置代理,batch-file,cmd,Batch File,Cmd,如何通过命令行或自动执行此操作的脚本为Waterbox中的每个配置文件设置代理。顺便说一下,我有50份个人资料 这是我想做的,但通过cmd行: 我想你可以找到更多关于这方面的信息。作为参考,这里是一个最被接受的答案 用于启用代理使用的命令: reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" ^ /v ProxyEnable /t REG_DWORD /d 1 /f reg add "HK

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

这是我想做的,但通过cmd行:

我想你可以找到更多关于这方面的信息。作为参考,这里是一个最被接受的答案

用于启用代理使用的命令:

reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" ^
    /v ProxyEnable /t REG_DWORD /d 1 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" ^
    /v ProxyEnable /t REG_DWORD /d 0 /f
用于禁用代理使用的命令:

reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" ^
    /v ProxyEnable /t REG_DWORD /d 1 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" ^
    /v ProxyEnable /t REG_DWORD /d 0 /f
更改代理地址的命令:

reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" ^
    /v ProxyServer /t REG_SZ /d proxyserveraddress:proxyport /f

为了提高可读性,我添加了行延续(^)。此外,在这种情况下,它更像是一个按用户设置,而不是一个系统范围的设置。

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

> pushd "%APPDATA%\Mozilla\Firefox\Profiles\*.default"
> more prefs.js

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

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

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

:: 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

我不会将代理更改为Internet设置。。我需要同时将其更改为许多FireFox的配置文件
cd/D“%APPDATA%\Mozilla\FireFox\Profiles”cd*。默认设置ffile=%cd%echo user\u pref(“network.proxy.http”,“192.168.1.235”);>“%ffile%\prefs.js”echo user\u pref(“network.proxy.http\u port”,80);>>“%ffile%\prefs.js”echo user_pref(“network.proxy.type”,1);>>%ffile%\prefs.js“set ffile=cd%windir%
找到了此项,但不适用于me@S.Walid不要发表冗长的代码注释——如果你的问题需要包含这些注释的话。