Adding exe file

How can i execute a exe file from a buttom.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

chiche115Author Commented:
Please help me.
Shell + F1
I think caraf_g was trying to get you to look up the help page on "Shell"...

In the click event of your button put this code:

   Shell "whatever.exe",vbNormalFocus

and the program will run with normal focus...



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Here's a function you can use to start a .exe file..

You can use it with code like..

  Call Run(exefilename)

Add this to the (declaration) part..

  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

And here's the function code..

  Function Run(strFilePath As String, Optional strParms As String, Optional strDir As String) As String
    Const SW_SHOW = 5
    'Run the Program and Evaluate errors
    Select Case ShellExecute(0, "Open", strFilePath, strParms, strDir, SW_SHOW)
    Case 0
      Run = "Insufficent system memory or corrupt program file"
    Case 2
      Run = "File not found"
    Case 3
      Run = "Invalid path"
    Case 5
      Run = "Sharing or Protection Error"
    Case 6
      Run = "Seperate data segments are required for each task"
    Case 8
      Run = "Insufficient memory to run the program"
    Case 10
      Run = "Incorrect Windows version"
    Case 11
      Run = "Invalid program file"
    Case 12
      Run = "Program file requires a different operating system"
    Case 13
      Run = "Program requires MS-DOS 4.0"
    Case 14
      Run = "Unknown program file type"
    Case 15
      Run = "Windows program does not support protected memory mode"
    Case 16
      Run = "Invalid use of data segments when loading a second instance of a program"
    Case 19
      Run = "Attempt to run a compressed program file"
    Case 20
      Run = "Invalid dynamic link library"
    Case 21
      Run = "Program requires Windows 32-bit extensions"
    Case Else
      Run = ""
    End Select

  End Function

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.