For Programmers: Free Programming Magazines  


Home > Archive > Windows Server Scripting > August 2005 > vbscript to change IE Proxy









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author vbscript to change IE Proxy
William Hymen

2005-08-08, 8:59 am

I am looking for a hard coded vbscript to plug in
the company proxy and exclusion list:
Connections -> LAN settings -> Proxy Server [advanced] [exceptions];
And another script to "uncheck" all that and enable "Automatically detect
settings"

We are having problems supporting home
users who want to connect to the company
intranet using a VPN client; then later
disconnect and surf the web using their own ISP.
(the ISP would use either NO proxy or automatically detect settings.

They all have cable modems and routers using DHCP.
But we don't support anything beyond the laptop;
that's up to the home user. ( we don't have enough staff to support
routers that they buy)

Nothing seems to work except changing the proxy.

Thanks to much in advance.

Bill


J Ford

2005-08-08, 8:59 am


Basically just right a script that r/w to the following registry location

HKCU\Software\Microsoft\Windows\CurrentV
ersion\Internet Settings
ProxyEnable <- REG_DWORD Val '0' Off, '1' On
ProxyOverride <- REG_SZ Val ';' delimited

Jeremy

"William Hymen" wrote:

> I am looking for a hard coded vbscript to plug in
> the company proxy and exclusion list:
> Connections -> LAN settings -> Proxy Server [advanced] [exceptions];
> And another script to "uncheck" all that and enable "Automatically detect
> settings"
>
> We are having problems supporting home
> users who want to connect to the company
> intranet using a VPN client; then later
> disconnect and surf the web using their own ISP.
> (the ISP would use either NO proxy or automatically detect settings.
>
> They all have cable modems and routers using DHCP.
> But we don't support anything beyond the laptop;
> that's up to the home user. ( we don't have enough staff to support
> routers that they buy)
>
> Nothing seems to work except changing the proxy.
>
> Thanks to much in advance.
>
> Bill
>
>
>

William Hymen

2005-08-10, 3:59 am

Thanks,

But I'm looking for some vbscript samples
from someone who has coded a working solution.

Thanks anyway!

Bill

"J Ford" <JFord@discussions.microsoft.com> wrote in message
news:B7F96ACF-A0E9-40F1-B99C-FB6B3B512B11@microsoft.com...[color=darkred]
>
> Basically just right a script that r/w to the following registry location
>
> HKCU\Software\Microsoft\Windows\CurrentV
ersion\Internet Settings
> ProxyEnable <- REG_DWORD Val '0' Off, '1' On
> ProxyOverride <- REG_SZ Val ';' delimited
>
> Jeremy
>
> "William Hymen" wrote:
>
detect[color=darkred]


J Ford

2005-08-10, 8:59 am

Here, you click it once it will enable it, you click it again it will disable
it:

<script>
Const HKCU=&H80000001 'HKEY_CURRENT_USER
Const HKLM=&H80000002 'HKEY_LOCAL_MACHINE

Const REG_SZ=1
Const REG_EXPAND_SZ=2
Const REG_BINARY=3
Const REG_DWORD=4
Const REG_MULTI_SZ=7

Const HKCU_IE_PROXY = " Software\Microsoft\Windows\CurrentVersio
n\Internet
Settings"

Set oReg=GetObject("winmgmts:!root/default:StdRegProv")

Main

Sub Main()

' If Proxy is set then turn it off
If GetValue(HKCU,HKCU_IE_PROXY,"ProxyEnable",REG_DWORD) = 1 AND
Len(GetValue(HKCU,HKCU_IE_PROXY,"ProxyServer",REG_SZ)) > 0 Then
CreateValue HKCU,HKCU_IE_PROXY,"ProxyEnable",0,REG_DWORD
wscript.echo "Proxy Disabled"
Else
' If Proxy is not set then turn it on

strProxyServer = "MyProxySvr:80"
strProxyOveride = "*.domain.com;*.domain2.com;*domain3.com"

CreateValue HKCU,HKCU_IE_PROXY,"ProxyServer",strProxyServer,REG_SZ
CreateValue HKCU,HKCU_IE_PROXY,"ProxyEnable",1,REG_DWORD
CreateValue HKCU,HKCU_IE_PROXY,"ProxyOverride",strProxyOveride,REG_SZ
wscript.echo "Proxy Enabled" & vbcrlf & "(" & strProxyServer & ")"
End If

End Sub

Function CreateValue(Key,SubKey,ValueName,Value,K
eyType)
Select Case KeyType
Case REG_SZ
CreateValue = oReg. SetStringValue(Key,SubKey,ValueName,Valu
e)
Case REG_EXPAND_SZ
CreateValue =
oReg. SetExpandedStringValue(Key,SubKey,ValueN
ame,Value)
Case REG_BINARY
CreateValue = oReg. SetBinaryValue(Key,SubKey,ValueName,Valu
e)
Case REG_DWORD
CreateValue = oReg. SetDWORDValue(Key,SubKey,ValueName,Value
)
Case REG_MULTI_SZ
CreateValue =
oReg. SetMultiStringValue(Key,SubKey,ValueName
,Value)
End Select
End Function

Function DeleteValue(Key, SubKey, ValueName)
DeleteValue = oReg.DeleteValue(Key,SubKey,ValueName)
End Function

Function GetValue(Key, SubKey, ValueName, KeyType)

Dim Ret

Select Case KeyType
Case REG_SZ
oReg.GetStringValue Key, SubKey, ValueName, Value
Ret = Value
Case REG_EXPAND_SZ
oReg.GetExpandedStringValue Key, SubKey, ValueName, Value
Ret = Value
Case REG_BINARY
oReg.GetBinaryValue Key, SubKey, ValueName, Value
Ret = Value
Case REG_DWORD
oReg.GetDWORDValue Key, SubKey, ValueName, Value
Ret = Value
Case REG_MULTI_SZ
oReg.GetMultiStringValue Key, SubKey, ValueName, Value
Ret = Value
End Select

GetValue = Ret
End Function
</script>

"William Hymen" wrote:

> Thanks,
>
> But I'm looking for some vbscript samples
> from someone who has coded a working solution.
>
> Thanks anyway!
>
> Bill
>
> "J Ford" <JFord@discussions.microsoft.com> wrote in message
> news:B7F96ACF-A0E9-40F1-B99C-FB6B3B512B11@microsoft.com...
> detect
>
>
>

William Hymen

2005-08-14, 9:59 pm

Thanks!

"J Ford" <JFord@discussions.microsoft.com> wrote in message
news:F788D88B-5A27-4482-8D93-2A503C4C69EA@microsoft.com...
> Here, you click it once it will enable it, you click it again it will

disable
> it:
>
> <script>
> Const HKCU=&H80000001 'HKEY_CURRENT_USER
> Const HKLM=&H80000002 'HKEY_LOCAL_MACHINE
>
> Const REG_SZ=1
> Const REG_EXPAND_SZ=2
> Const REG_BINARY=3
> Const REG_DWORD=4
> Const REG_MULTI_SZ=7
>
> Const HKCU_IE_PROXY = " Software\Microsoft\Windows\CurrentVersio
n\Internet
> Settings"
>
> Set oReg=GetObject("winmgmts:!root/default:StdRegProv")
>
> Main
>
> Sub Main()
>
> ' If Proxy is set then turn it off
> If GetValue(HKCU,HKCU_IE_PROXY,"ProxyEnable",REG_DWORD) = 1 AND
> Len(GetValue(HKCU,HKCU_IE_PROXY,"ProxyServer",REG_SZ)) > 0 Then
> CreateValue HKCU,HKCU_IE_PROXY,"ProxyEnable",0,REG_DWORD
> wscript.echo "Proxy Disabled"
> Else
> ' If Proxy is not set then turn it on
>
> strProxyServer = "MyProxySvr:80"
> strProxyOveride = "*.domain.com;*.domain2.com;*domain3.com"
>
> CreateValue HKCU,HKCU_IE_PROXY,"ProxyServer",strProxyServer,REG_SZ
> CreateValue HKCU,HKCU_IE_PROXY,"ProxyEnable",1,REG_DWORD
> CreateValue HKCU,HKCU_IE_PROXY,"ProxyOverride",strProxyOveride,REG_SZ
> wscript.echo "Proxy Enabled" & vbcrlf & "(" & strProxyServer & ")"
> End If
>
> End Sub
>
> Function CreateValue(Key,SubKey,ValueName,Value,K
eyType)
> Select Case KeyType
> Case REG_SZ
> CreateValue =

oReg. SetStringValue(Key,SubKey,ValueName,Valu
e)
> Case REG_EXPAND_SZ
> CreateValue =
> oReg. SetExpandedStringValue(Key,SubKey,ValueN
ame,Value)
> Case REG_BINARY
> CreateValue =

oReg. SetBinaryValue(Key,SubKey,ValueName,Valu
e)
> Case REG_DWORD
> CreateValue =

oReg. SetDWORDValue(Key,SubKey,ValueName,Value
)
> Case REG_MULTI_SZ
> CreateValue =
> oReg. SetMultiStringValue(Key,SubKey,ValueName
,Value)
> End Select
> End Function
>
> Function DeleteValue(Key, SubKey, ValueName)
> DeleteValue = oReg.DeleteValue(Key,SubKey,ValueName)
> End Function
>
> Function GetValue(Key, SubKey, ValueName, KeyType)
>
> Dim Ret
>
> Select Case KeyType
> Case REG_SZ
> oReg.GetStringValue Key, SubKey, ValueName, Value
> Ret = Value
> Case REG_EXPAND_SZ
> oReg.GetExpandedStringValue Key, SubKey, ValueName,

Value[color=darkred]
> Ret = Value
> Case REG_BINARY
> oReg.GetBinaryValue Key, SubKey, ValueName, Value
> Ret = Value
> Case REG_DWORD
> oReg.GetDWORDValue Key, SubKey, ValueName, Value
> Ret = Value
> Case REG_MULTI_SZ
> oReg.GetMultiStringValue Key, SubKey, ValueName, Value
> Ret = Value
> End Select
>
> GetValue = Ret
> End Function
> </script>
>
> "William Hymen" wrote:
>
location[color=darkred]


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com