Results 1 to 8 of 8

Thread: Launching IE as an Object [RESOLVED]

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Location
    Chicago
    Posts
    136

    Question Launching IE as an Object [RESOLVED]

    I'm using the code below to launch IE and navigate to a website. I'm having a problem with it because the site it goes to uses cookies for user sessions. The cookie contains, among other information, the user's login name. There is also another program that uses the same method to launch IE that goes to the same page, however, it requires a different log in to access different parts of the site. Currently people who launch one program first aren't able to login if they try to launch the second program. If they manually go to the website and do it it works though. Anyone have any ideas as to why this is happening?


    Code for first app:
    VB Code:
    1. Private Sub Form_Load()
    2.  
    3. Dim objMSIE1
    4. Dim boolFileExists As Boolean
    5. Dim strNotFound As String
    6.  
    7. Set objMSIE1 = CreateObject("InternetExplorer.Application")
    8. If Err.Number = 0 Then 'No error
    9.             boolFileExists = True
    10.             outrc = 0
    11.         Else
    12.             boolFileExists = False
    13.             strNotFound = "I cannot find Internet Explorer." & vbCrLf & "Please download Internet Explorer from www.microsoft.com/windows/ie"
    14.             MsgBox strNotFound, vbCritical, "Application Error"
    15.             outrc = 1
    16.             Exit Sub
    17.         End If
    18.  
    19. objMSIE1.Navigate ("https://website/")
    20. objMSIE1.Visible = True
    21.  
    22. Set objMSIE1 = Nothing
    23. Unload Me
    24. End
    25. End Sub


    Code for second app:
    VB Code:
    1. Private Sub Form_Load()
    2.  
    3. Dim objMSIE
    4. Dim boolFileExists As Boolean
    5. Dim strNotFound As String
    6.  
    7. Set objMSIE = CreateObject("InternetExplorer.Application")
    8. If Err.Number = 0 Then 'No error
    9.             boolFileExists = True
    10.             outrc = 0
    11.         Else
    12.             boolFileExists = False
    13.             strNotFound = "I cannot find Internet Explorer." & vbCrLf & "Please download Internet Explorer from www.microsoft.com/windows/ie"
    14.             MsgBox strNotFound, vbCritical, "Application Error"
    15.             outrc = 1
    16.             Exit Sub
    17.         End If
    18.  
    19. objMSIE.Navigate ("https://website/")
    20. objMSIE.Visible = True
    21.  
    22. Set objMSIE = Nothing
    23. Unload Me
    24. End
    25. End Sub
    Last edited by bat711; Apr 15th, 2005 at 11:10 AM.

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Location
    Chicago
    Posts
    136

    Re: Launching IE as an Object

    I'm pretty sure this can be solved by launching IE as separate processes, so that each would have it's own process ID. Is there some way to set it up so that they are unique processes?

    It's similar to this posting (unresolved):

    http://www.vbforums.com/showthread.php?t=162748
    Last edited by bat711; Apr 14th, 2005 at 12:38 PM.

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Launching IE as an Object

    See Post #4 here by TheVader. Is that what you mean?

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Location
    Chicago
    Posts
    136

    Re: Launching IE as an Object

    It looks like the same method to start an IE object, it's just that I need each IE to be a separate process. For example, when you use Internet Explorer and use the right-click 'Open in New Window' command it still lists only one 'IExplore.exe' in the Task Manager processes list. However, if you click the IE icon to start a new Internet Explorer it creates a new 'IExplore.exe' process.

    Is there a way to launch IE and specify you want it as a new process?

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Launching IE as an Object

    TheVader's code will launch each instance of IE in a new window. It will not use a previous opened window.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Location
    Chicago
    Posts
    136

    Re: Launching IE as an Object

    That's what mine will do as well, the problem is they are all run under the same Process ID. If you launch it to two times it will instantiate two browsers but one process. This becomes a problem when you are working with secure websites.

    You can see what I'm talking about if you start Task Manager and go to the processes tab. Launch Internet Explorer to a website with 'TheVader' or my code. You will only see one process of 'IExplore.exe' start up with two instances of the browser windows open (provided you don't have other browsers open besides these two). Now if you launch IE by clicking the icon to start two browsers you will see 'IExplore.exe' listed twice with two unique process ID's.

    I guess I could just use Shell instead and see if that brings up two separate processes, which I'm sure it will just a little messier than using objects.
    Last edited by bat711; Apr 14th, 2005 at 03:07 PM.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Location
    Chicago
    Posts
    136

    Re: Launching IE as an Object

    In case anyone is interested here is a good explanation. It's the third question down:

    http://msdn.microsoft.com/msdnmag/issues/04/05/WebQA/

    I wish we were using .NET here, this would be so simple...

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Location
    Chicago
    Posts
    136

    Re: Launching IE as an Object

    In case anyone else is interested in this problem the only way to resolve it is to call the .EXE directly to create multiple IE processes. Any of the simpler object based ways only create multiple threads and one process.

    Below is some code I made for this that finds the location of IExplore.exe through the registry and then launches a website. The registry module is attached.

    VB Code:
    1. Option Explicit
    2. Const HKEY_CLASSES_ROOT = &H80000000
    3. Const HKEY_CURRENT_USER = &H80000001
    4. Const HKEY_LOCAL_MACHINE = &H80000002
    5. Const HKEY_USERS = &H80000003
    6.  
    7.     ' Reg Key Security Options...
    8. Const READ_CONTROL = &H20000
    9. Const KEY_QUERY_VALUE = &H1
    10. Const KEY_SET_VALUE = &H2
    11. Const KEY_CREATE_SUB_KEY = &H4
    12. Const KEY_ENUMERATE_SUB_KEYS = &H8
    13. Const KEY_NOTIFY = &H10
    14. Const KEY_CREATE_LINK = &H20
    15. Const KEY_ALL_ACCESS = KEY_QUERY_VALUE + KEY_SET_VALUE + _
    16.                        KEY_CREATE_SUB_KEY + KEY_ENUMERATE_SUB_KEYS + _
    17.                        KEY_NOTIFY + KEY_CREATE_LINK + READ_CONTROL
    18.  
    19. Private Sub Form_Load()
    20.  
    21. Dim strSubKey As String
    22. Dim strValueName As String
    23. Dim AppPath As String
    24. Dim AppPathLen As Integer
    25.  
    26. 'Registry value locations
    27. strSubKey = "SOFTWARE\Classes\Applications\iexplore.exe\shell\open\command"
    28. strValueName = ""
    29.  
    30. 'Returning the application path back from registry
    31. AppPath = RegGetValue$(HKEY_LOCAL_MACHINE, strSubKey, strValueName)
    32.  
    33.  
    34. 'Determining the length of the path
    35. AppPathLen = Len(AppPath)
    36. 'Removing the " %1" from the end of the path
    37. AppPath = Left(AppPath, AppPathLen - 3)
    38. 'Adding the site to be navigated to
    39. AppPath = AppPath & " website"
    40.  
    41. 'Launching IE
    42. Shell AppPath, vbNormalFocus
    43.  
    44. End
    45. End Sub
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width