simple proxy settings question

Hopefully someone can help me in creating a simple, double-clickable .exe and script which need to do the following (I have a user who is co-located and needs to bypass the proxy server for a particular site, and internal address settings are not applicable):

-Set ProxyEnable to 1 under HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\InternetSettings

-Launch IE 5 to a specific URL

-Set ProxyEnable to 0 when the script and/or browser window is stopped/closed
VBDJamesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Richie_SimonettiIT OperationsCommented:
couldn't you change directly in proxy settings config of IE?
I mean, in Conections, lan config, advanced settings you could tell IE that not use proxy to severals urls (including partial ones) separatted each entry by comma.
0
VBDJamesAuthor Commented:
Yes, I could change the proxy settings directly, but URL exceptions are a Corporate policy no-no (don't ask)... anything done must isolated to per-session usage.  Also, dyslexic as I am, invert the ProxyEnable boolean order...
0
Richie_SimonettiIT OperationsCommented:
Try:
Option Explicit

Private Enum hKeyConstants
    HKEY_CLASSES_ROOT = &H80000000
    HKEY_CURRENT_USER = &H80000001
    HKEY_LOCAL_MACHINE = &H80000002
    HKEY_USERS = &H80000003
    HKEY_PERFORMANCE_DATA = &H80000004
    HKEY_CURRENT_CONFIG = &H80000005
    HKEY_DYN_DATA = &H80000006
End Enum

Private Enum RegTypeConstants
'    REG_NONE = (0)
    REG_SZ = (1)                           ' NULL
'    REG_EXPAND_SZ = (2)
'    REG_BINARY = (3)                       '
    REG_DWORD = (4)                        ' 32
    REG_DWORD_LITTLE_ENDIAN = (4)          '  32
'    REG_DWORD_BIG_ENDIAN = (5)             ' 32
'    REG_LINK = (6)                         ' Unicode
'    REG_MULTI_SZ = (7)                     ' NULL
'    REG_RESOURCE_LIST = (8)                '
End Enum


Private Const ERROR_SUCCESS     As Long = 0

Private Declare Function SHSetValue Lib "SHLWAPI.DLL" Alias "SHSetValueA" _
                                (ByVal hkey As Long, _
                                 ByVal pszSubKey As String, _
                                 ByVal pszValue As String, _
                                 ByVal dwType As Long, _
                                 pvData As Any, _
                                 ByVal cbData As Long) As Long

Public Function RegSetValue(lnghInKey As hKeyConstants, _
                            ByVal strSubKey As String, _
                            ByVal strValName As String, _
                            lngType As RegTypeConstants, _
                            ByVal varValue As Variant) As Boolean
    ' lngInKey   : [
    ' strSubKey  :
    ' strValName :
    ' lngType    :
    ' varValue   :
    ' –ß‚è’l     : True, False
    Dim lnghSubKey          As Long
    Dim lngValue            As Long
    Dim strValue            As String
    Dim lngResult           As Long
    '
    RegSetValue = False
    Select Case lngType
        Case REG_DWORD, REG_DWORD_LITTLE_ENDIAN
            '
            lngValue = CLng(varValue)
            lngResult = SHSetValue(lnghInKey, _
                                   strSubKey, _
                                   strValName, _
                                   REG_DWORD, _
                                   lngValue, _
                                   Len(lngValue))
            RegSetValue = (lngResult = ERROR_SUCCESS)
        Case REG_SZ
            '
            strValue = CStr(varValue)
           
            lngResult = SHSetValue(lnghInKey, _
                                   strSubKey, _
                                   strValName, _
                                   REG_SZ, _
                                   ByVal strValue, _
                                   CLng(LenB(StrConv(strValue, vbFromUnicode)) + 1))
            RegSetValue = (lngResult = ERROR_SUCCESS)
    End Select
End Function

Private Sub Form_Load()
RegSetValue HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\internet settings", "ProxyEnable", REG_DWORD, &H0
Dim ie As Object
Set ie = CreateObject("internetexplorer.application")
If Not ie Is Nothing Then
    With ie
        .navigate "www.somesite.com/index.html"
        Do While .readystate <> 4
            DoEvents
        Loop
    End With
End If
RegSetValue HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\internet settings", "ProxyEnable", REG_DWORD, &H1
End Sub
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Richie_SimonettiIT OperationsCommented:
You could see the manage Registry code at:
http://plaza5.mbn.or.jp/~heropa/vb123.htm
0
Richie_SimonettiIT OperationsCommented:
Sorry, little changes:


Option Explicit

Private Enum hKeyConstants
    HKEY_CLASSES_ROOT = &H80000000
    HKEY_CURRENT_USER = &H80000001
    HKEY_LOCAL_MACHINE = &H80000002
    HKEY_USERS = &H80000003
    HKEY_PERFORMANCE_DATA = &H80000004
    HKEY_CURRENT_CONFIG = &H80000005
    HKEY_DYN_DATA = &H80000006
End Enum

Private Enum RegTypeConstants
'    REG_NONE = (0)
    REG_SZ = (1)                           ' NULL
'    REG_EXPAND_SZ = (2)
'    REG_BINARY = (3)                       '
    REG_DWORD = (4)                        ' 32
    REG_DWORD_LITTLE_ENDIAN = (4)          '  32
'    REG_DWORD_BIG_ENDIAN = (5)             ' 32
'    REG_LINK = (6)                         ' Unicode
'    REG_MULTI_SZ = (7)                     ' NULL
'    REG_RESOURCE_LIST = (8)                '
End Enum


Private Const ERROR_SUCCESS     As Long = 0

Private Declare Function SHSetValue Lib "SHLWAPI.DLL" Alias "SHSetValueA" _
                                (ByVal hkey As Long, _
                                 ByVal pszSubKey As String, _
                                 ByVal pszValue As String, _
                                 ByVal dwType As Long, _
                                 pvData As Any, _
                                 ByVal cbData As Long) As Long

Private Function RegSetValue(lnghInKey As hKeyConstants, _
                            ByVal strSubKey As String, _
                            ByVal strValName As String, _
                            lngType As RegTypeConstants, _
                            ByVal varValue As Variant) As Boolean
    ' lngInKey   : [
    ' strSubKey  :
    ' strValName :
    ' lngType    :
    ' varValue   :
    ' –ß‚è’l     : True, False
    Dim lnghSubKey          As Long
    Dim lngValue            As Long
    Dim strValue            As String
    Dim lngResult           As Long
    '
    RegSetValue = False
    Select Case lngType
        Case REG_DWORD, REG_DWORD_LITTLE_ENDIAN
            '
            lngValue = CLng(varValue)
            lngResult = SHSetValue(lnghInKey, _
                                   strSubKey, _
                                   strValName, _
                                   REG_DWORD, _
                                   lngValue, _
                                   Len(lngValue))
            RegSetValue = (lngResult = ERROR_SUCCESS)
        Case REG_SZ
            '
            strValue = CStr(varValue)
           
            lngResult = SHSetValue(lnghInKey, _
                                   strSubKey, _
                                   strValName, _
                                   REG_SZ, _
                                   ByVal strValue, _
                                   CLng(LenB(StrConv(strValue, vbFromUnicode)) + 1))
            RegSetValue = (lngResult = ERROR_SUCCESS)
    End Select
End Function

Private Sub Form_Load()
RegSetValue HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\internet settings", "ProxyEnable", REG_DWORD, &H0
Dim ie As Object
Set ie = CreateObject("internetexplorer.application")
If Not ie Is Nothing Then
    With ie
        .navigate "www.hotmail.com"
        .Visible = True
        Do While .readystate <> 4
            DoEvents
        Loop
    End With
End If
RegSetValue HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\internet settings", "ProxyEnable", REG_DWORD, &H1
End Sub

But i don't know if with this you got what you want.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
VBDJamesAuthor Commented:
That worked... thanx a ton.
0
CleanupPingCommented:
VBDJames:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0
Richie_SimonettiIT OperationsCommented:
Well, i don't know really but except you, there are only two possible candidate :)
0
DanRollinsCommented:
Moderator, my recommended disposition is:

    Accept Richie_Simonetti's comment(s) as an answer.
    *** Flipped a coin to decide.... :-)

DanRollins -- EE database cleanup volunteer
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.