开发者

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

开发者 https://www.devze.com 2023-02-07 19:12 出处:网络
I have various types of VM\'s running that I\'d like to use my local machine\'s proxy settings. This way any browser activity from the VM would go through the host proxy even if the VM\'s proxy settin

I have various types of VM's running that I'd like to use my local machine's proxy settings. This way any browser activity from the VM would go through the host proxy even if the VM's proxy settings are turned off. 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. But I'm not able to find the magic answer to getting the VM's to go through the proxy instea开发者_JAVA百科d of bypassing.

Help?


I've had luck with the following reg hack for 32bit:

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

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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号