Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Const SHOWNORMAL = 1
Private Sub Command1_Click()
Dim bAutoEjecutable As Boolean
Dim Archivo, Ext
Archivo = Me.Text1 '"C:\Archivos de programa\MSN Messenger\msnmsgr.exe"
Ext = UCase(Right(Archivo, 3))
bAutoEjecutable = InStr(Environ("PATHEXT"), Ext) > 0
If bAutoEjecutable Then
Shell Archivo, vbNormalFocus
Else
ShellExecute Me.hwnd, "Open", Archivo, &O0, &O0, SHOWNORMAL
End If
End Sub