Hey guys,

I'm using kleinma's code to open a web browser after a user
installs the software that goes to a thank you page on my
site. I wanted to have it launch a few seconds after install
in their default browser which is why I'm using this code below.

I put in a timer into the form but am unfamiliar with how to
use it specifically with kleinma's code.

Anyone know how I can do this? And also specify the height
and width of the page?


vb Code:
  1. Public Sub LaunchNewBrowser(ByVal strUrl As String)
  2.         Try
  3.             'CREATE SOME VARIABLES
  4.             Dim BrowserExec As String = New String(" "c, 255)
  5.             Dim FileName As String
  6.             Dim RetVal As Long
  7.             Dim SWriter As StreamWriter
  8.             'CREATE A TEMP HTM FILE SO WE CAN FIND OUT WHAT BROWSER IS
  9.             'THE DEFAULT ONE ON THE SYSTEM
  10.             FileName = Application.StartupPath & "\temp.htm"
  11.             Try
  12.                 SWriter = File.CreateText(FileName)
  13.                 SWriter.Write("<html></html>")
  14.                 SWriter.Close()
  15.             Catch ex As Exception
  16.                 'IF ANYTHING GOES WRONG, TRY TO DO A STANDARD PROCESS LAUNCH
  17.                 BackupLaunch(strUrl)
  18.                 Return
  19.             End Try
  20.             'CALL THE API TO FIND THE EXE ASSOCIATED WITH HTM FILES
  21.             RetVal = FindExecutable(FileName, vbNullString, BrowserExec)
  22.             BrowserExec = BrowserExec.Trim
  23.             'IF WE GET ONE, LAUNCH THE URL IN THE NEW INSTANCE OF THE BROWSER
  24.             If RetVal <= 32 OrElse BrowserExec = String.Empty Then
  25.                 MessageBox.Show("Could not find a valid web browser")
  26.             Else
  27.                 Process.Start(BrowserExec, New UriBuilder(strUrl).Uri.AbsoluteUri)
  28.             End If
  29.             Try 'DELETE THAT PESKY TEMP FILE
  30.                 File.Delete(FileName)
  31.             Catch ex As Exception 'NOT GOING TO DO ANYTHING, MIGHT WANT TO LOG IT OR SOMETHING
  32.             End Try
  33.         Catch ex As Exception
  34.             'IF ANYTHING GOES WRONG, TRY TO DO A STANDARD PROCESS LAUNCH
  35.             BackupLaunch(strUrl)
  36.         End Try
  37.     End Sub
  38.     'THIS IS USED INCASE THE MAIN ROUTINE FAILS, SO WE TRY TO AT LEAST TO THE LAUNCH ANYWAY,
  39.     'EVEN THOUGH IT WILL BE IN AN ALREADY OPEN WINDOW. ITS A SECOND SUB BC ITS USED MORE THAN
  40.     'ONCE IN THE MAIN ROUTINE
  41.     Private Sub BackupLaunch(ByVal strURL As String)
  42.         Try
  43.             Process.Start(strURL)
  44.         Catch ex As Exception
  45.             MessageBox.Show("Could not launch website. Error Unknown.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
  46.         End Try
  47.     End Sub
  48.  
  49. End Module

Chris