简体   繁体   English

如何强制VM使用C#中的主机代理设置?

[英]How can I force VM's to use the host proxy settings from C#?

I have various types of VM's running that I'd like to use my local machine's proxy settings. 我有多种类型的VM正在运行,我想使用本地计算机的代理设置。 This way any browser activity from the VM would go through the host proxy even if the VM's proxy settings are turned off. 这样,即使VM的代理设置已关闭,来自VM的任何浏览器活动都将通过主机代理。 But they seem to ignore the settings and just go straight out to the internet bypassing the proxy. 但是他们似乎忽略了设置,只是绕过代理直接进入了互联网。

I have a WinInet settings being setup via winhttp.dll and wininet.dll external calls. 我通过winhttp.dll和wininet.dll外部调用设置了WinInet设置。 But I'm not able to find the magic answer to getting the VM's to go through the proxy instead of bypassing. 但我无法找到让VM通过代理而不是绕过的神奇答案。

Help? 救命?

I've had luck with the following reg hack for 32bit: 我对以下32位的reg hack感到很幸运:

REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings" /v MigrateProxy /t REG_DWORD /d 0x1 /f
REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0x1 /f
REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t REG_SZ /d myproxy.local:3128 /f
REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyOverride /t REG_SZ /d ^<local^>; /f
REG ADD "HKLM\Software\Policies\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxySettingsPerUser /t REG_DWORD /d 0x0 /f

For 64bit I've had less luck, but this works for browsers. 对于64位,我运气较差,但这适用于浏览器。 :

REG ADD "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Internet Settings" /v MigrateProxy /t REG_DWORD /d 0x1 /f
REG ADD "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0x1 /f
REG ADD "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t REG_SZ /d myproxy.local:3128 /f
REG ADD "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyOverride /t REG_SZ /d ^<local^>; /f
REG ADD "HKLM\Software\Policies\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxySettingsPerUser /t REG_DWORD /d 0x0 /f
REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings" /v MigrateProxy /t REG_DWORD /d 0x1 /f
REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0x1 /f
REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t REG_SZ /d myproxy.local:3128 /f
REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyOverride /t REG_SZ /d ^<local^>; /f

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何强制C#FtpWebRequest使用直接IP而不是通过HTTP代理进入Internet? - How can I force a C# FtpWebRequest to use a direct IP to get onto the Internet instead of going through an HTTP proxy? 如何强制应用程序仅使用c#中指定路径的库? - How can I force the application to use only library from the specified path in c#? 如何在 c# 中为 Google Cloud Txt-To-Speech API 设置代理设置 - How can I setup proxy settings in c# for Google Cloud Txt-To-Speech API C# 强制 windows 服务使用代理 - C# force windows service to use proxy 如何从系统服务自动检测代理设置 - How can I automatically detect proxy settings from system service 使用 NSIS 部署 C# Winforms 应用程序时,如何使用 Properties.Settings? - How can I use Properties.Settings when I deploy my C# Winforms app with NSIS? 如何使C#项目的设置成为用户特定的? - How can I make a C# project's settings be user specific? C# WPF 我如何将数据从用户控制传递到主 VM - C# WPF How i can pass data from User Control to Main VM 我可以强制C#/ .NET使用最新版本的程序集 - Can I force C#/.NET to use the newest version of assembly 我可以在 c# .NET 中强制使用“this”关键字吗? - Can I force the use of 'this' keyword in c# .NET?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM