?
Solved

simple proxy settings question

Posted on 2003-02-27
9
Medium Priority
?
734 Views
Last Modified: 2012-06-27
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
0
Comment
Question by:VBDJames
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8036166
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
 

Author Comment

by:VBDJames
ID: 8036380
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8037018
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8037024
You could see the manage Registry code at:
http://plaza5.mbn.or.jp/~heropa/vb123.htm
0
 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 200 total points
ID: 8037053
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
 

Author Comment

by:VBDJames
ID: 8197113
That worked... thanx a ton.
0
 

Expert Comment

by:CleanupPing
ID: 8940435
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8942458
Well, i don't know really but except you, there are only two possible candidate :)
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8983800
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month9 days, 21 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question