Results 1 to 4 of 4

Thread: Running another program from within

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2001
    Location
    Minnesota
    Posts
    91

    Running another program from within

    How do I run another VB program like call it to open it from within another program?

    -=thanks!=-

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    shell "c:\myprogram.exe"
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2001
    Location
    Minnesota
    Posts
    91
    duh! gracias

  4. #4
    Junior Member
    Join Date
    Jan 2002
    Location
    Shrewsbury, Shropshire, UK.
    Posts
    30
    Use the shell command. Like this:

    Sub Command1_Click()
    Shell "c:\winnt\notepad.exe"
    End Sub

    The above would launch the notepad application when you clicked the button.

    There are various parameters that you add to the end of the command, which define how and if the window should be displayed. For example:

    Shell "c:\winnt\notepad.exe",vbMinimized would cause notepad to load, but the window would be minimised to the task bar.

    I often dynamically create a batch file in my VB code, and then 'shell' out to the batch file to execute it. This can be handy when you have numerous operations (with files etc) to perform.

    Eg to delete the contents of all files in directories called '1' to '10'

    Dim i as integer, fp as integer
    fp=freefile()
    open "\mycmd.bat" for output as #fp
    for i=1 to 10
    print #fp,"cd "+Cstr(i)
    print #fp,"del *.*"
    print #fp,"cd.."
    next i
    close #fp
    shell "\mycmd.exe"

    The above would create a batch file, and physically run it. Hope this helps.
    Ouch. My head hurts.

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