Results 1 to 2 of 2

Thread: Search for an EXE on C: and run it

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Posts
    6

    Post

    I have no clue how to do this...

    I want to search for a EXE. Like VB.EXE for example.

    After if finds VB.EXE, It will run that exe using SHELL command.

    Thank you

  2. #2
    Hyperactive Member venkatraman_r's Avatar
    Join Date
    Jul 1999
    Location
    Chennai, INDIA
    Posts
    284

    Post

    This will list all the files in a listbox..

    Add a command button and a drive list control:

    In the declarations of the form:
    -------------------------------
    Private Sub FindIt(sStartPath As String, sPattern As String)
    On Error GoTo VenError:
    Dim fso As FileSystemObject
    Dim fld As Folder
    Dim fldCurrent As Folder
    Dim sFile As String

    Screen.MousePointer = vbHourglass

    Set fso = New FileSystemObject
    If right$(sStartPath, 1) <> "\" Then
    sStartPath = sStartPath & "\"
    End If

    Set fldCurrent = fso.GetFolder(sStartPath)
    sFile = Dir(sStartPath & sPattern, vbNormal)

    Do While Len(sFile) > 0
    List1.AddItem sStartPath & sFile
    sFile = Dir
    Loop
    VenError:
    If Err.Number = 76 Then
    MsgBox "Drive Access Error...Please Check Drive", vbOKOnly + vbCritical, "Drive Access Error"
    End If
    Screen.MousePointer = vbNormal
    End Sub

    *******************
    In a command button
    *******************
    Call FindIt(Drive1.Drive & "\", "*.exe")

    select the file from the listbox and use the shell command to run it.\

    Hope it works.

    Good Luck.

    Venkat.

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