Distribute programs without losing the path/path at runtime

Asked

Viewed 56 times

0

Good evening friends, I’m having a difficulty, my project is a button that when you click it opens an executable, I want to publish my project along with the program without losing the way when running on another machine..

2 answers

1

Assuming both executables are in the same folder, you will have to use Directory.GetCurrentDirectory(), an example of folder structure:

projeto
├── programa.exe
└── resources
    ├── app1.exe
    ├── app2.exe
    └── app3.exe

Having a structure similar to this, you can create a function to call it whenever you run a particular app, example:

Function ChamarApp(app As String)
    Dim Filename As String

    Filename = Directory.GetCurrentDirectory() & "\resources\" & app

    Shell("Start.exe " & Filename, vbHide)
End Function

To use simply call, as in the example:

ChamarApp("app1.exe") 'Chama o primeiro aplicativo
ChamarApp("app2.exe") 'Chama o segundo aplicativo
ChamarApp("app3.exe") 'Chama o terceiro aplicativo

0

In vb6 you use the command App.Path to return the path of the executable.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.