I'm trying to call other EXE's from my program I'm writing. Inside my project I have a folder called progs with exe's inside it. How can I call these from button clicks?

Use System.Diagnostics.Process class.

Process.Start("c:\windows\system32\calc.exe")

I've seen that before, but I wasn't sure how to call an exe that is inside my program.

Hey guys, here is an more advanced way to call the exe.

Process.Start(My.Application.Info.DirectoryPath & "\progs\calc.exe")

Hope that helped.

Thanks,
Marais

Okay. I tried your code that you provided above. In my solution explorer i have the following structure.

PROG ROOT
- a.vb
- b.vb
+ Resources
+ Prog
- Test1
- Test2
-Test2Sub1.exe

I used the below code but got a Win32Exception was unhandled.

Process.Start(My.Application.Info.DirectoryPath & "\Prog\Test2\Test2Sub1.exe")

>I've seen that before, but I wasn't sure how to call an exe that is inside my program.

And we don't know where your program is? Is your program is located at "c:\folder1" or somewhere else?

To get the path of current folder (This is the location where an executable of your program is located)

str=My.Computer.FileSystem.CurrentDirectory

Put your executables (.exe) under Bin\Debug or Bin\Debug (whatever is your current build) and use following path,

str=My.Computer.FileSystem.CurrentDirectory  & "\file1.exe"

Edited 5 Years Ago by __avd: n/a

I wasn't adding it the way that you just suggested. I'm sure if I do that way, it will solve it.

I guess I only have one more question for this thread. After I have completed my project, how can I just get the exe to add to a USB thumb drive to run on multiple computers. I don't want to create an installer for it.

Edited 5 Years Ago by MaddTechwf: n/a

>I don't want to create an installer for it.

Be sure that a .net framework (suitable version) must be installed on target machine.

Edited 5 Years Ago by __avd: n/a

You want to run a program using another program.:-/

try this:

suppose you have:
main.exe
sub1.exe
sub2.exe

and you want to run sub1.exe by clicking button1 in the main.exe.

and your sub1.exe is inside the folder named Prog.


the directory should be like this:
main1.exe
Prog/sub1.exe
Prog/sub2.exe


then use this:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Process.Start(Application.StartupPath & "/Prog/sub1.exe")
    End Sub

Goodluck! :)

This question has already been answered. Start a new discussion instead.