Results 1 to 3 of 3

Thread: execute an external program

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    6

    Talking

    Hi,

    I wonder how i can execute another program from a vb program? Do i need a reference or something. Is there a file.execute method somewhere?


  2. #2
    Guest
    You can use the Shell function.

    eg

    Code:
    Dim i as long
    
    i=o
    i = Shell("c:\calc.exe")
    If i = 0 Then
        MsgBox "Program startup failed"
    End if
    Shell returns the programs ID if it is successful or 0 if it isn't. There are also options on how to load up the program (maximised, minimsed, etc).

    Sunny

  3. #3
    Guest
    Use the ShellExecute api function instead of Shell.

    Code:
    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
    
    Public Const SW_SHOWNORMAL = 1
    Public Const SW_ShowMinimized = 2
    Public Const SW_SHOWMAXIMIZED = 3
    Public Const SW_Hide = 0
    
    ShellExecute Me.hwnd, vbNullString, "C:\file.exe", vbNullString, "c:\", SW_SHOWNORMAL

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