VBS - 如何获取计算机的 DOMAIN 代理设置?
VB 脚本文件中的以下代码将允许我获取计算机上启用代理的标志。例如,我的机器上没有启用代理,因此它返回“0”。
然而,这些是 Windows 域计算机,在大多数情况下我什么也得不到 - 不是 0,而是空白。
我假设这是因为我有一个强制代理设置(打开)的域策略。
那么,问题是我该如何阅读?它是不同的注册表项,还是我必须以某种方式读取完全不同的内容(例如网络设置)?
const HKEY_CURRENT_USER = &H80000001
Set oReg=GetObject( _
"winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Internet Settings"
strValueName = "ProxyEnable"
oReg.GetDWORDValue _
HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue
The following code in a VB Script file will allow me to get the proxy enabled flag on a machine. For example, I do not have the proxy enabled on my machine, so it returns "0".
However, these are Windows Domain computers and in most cases I am getting back nothing - not 0, but a blank.
I am assuming this is because I have a domain policy that is enforcing the proxy settings (as ON).
SO, the question is how do I read that? Is it a different registry key, or do I have to read something completely different like network settings somehow?
const HKEY_CURRENT_USER = &H80000001
Set oReg=GetObject( _
"winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Internet Settings"
strValueName = "ProxyEnable"
oReg.GetDWORDValue _
HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果注册表项
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings
中的注册表值ProxySettingsPerUser
为 1,则代理是按用户定义的(即可检索)从HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings
键)。如果 ProxySettingsPerUser 为 0,则为整个计算机定义代理(即代理设置存储在 HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Internet Settings 中)。
If registry value
ProxySettingsPerUser
in keyHKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings
is 1, then the proxy is defined per user (i.e. it can be retrieved from theHKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings
key).If
ProxySettingsPerUser
is 0, then the proxy is defined for the whole computer (i.e. the proxy settings are stored inHKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Internet Settings
).