How to run process from root folder

K

kimiraikkonen

Hello,
I want my external app run without specifying a certain path. It's
enough to be in the same folder with my vb.net exe.

System.Diagnostics.Process.Start("c:\3rdpartyapp.exe") is not OK for
me because everyuser should put it into c:\

i tried:

System.Diagnostics.Process.Start("3rdpartyapp.exe") with no success.
How can i specify root folder?
 
H

Herfried K. Wagner [MVP]

kimiraikkonen said:
I want my external app run without specifying a certain path. It's
enough to be in the same folder with my vb.net exe.

\\\
Imports System.Diagnostics
Imports System.IO
....
Dim ExecutablePath As String
ExecutablePath = Path.Combine(Application.StartupPath, "foo.exe")
Process.Run(ExecutablePath)
///
 
K

kimiraikkonen

\\\
Imports System.Diagnostics
Imports System.IO
...
Dim ExecutablePath As String
ExecutablePath = Path.Combine(Application.StartupPath, "foo.exe")
Process.Run(ExecutablePath)
///

Is there a shorter way?
 
R

rowe_newsgroups

Is there a shorter way?

Shorter way? Why the heck does that matter?

Anyways, you could do it in one giant, sloppy (imo), line:

Process.Run(Path.Combine(Application.StartupPath, "foo.exe"))

However, in my opinion being verbose is much better than trying to
make a "short" program. When you go to in to perform maintenance on
your code it is much more difficult to work with compact code.

Thanks,

Seth Rowe
 
P

Patrice

You could create a sub or function that take the exe file as an argument if
you need to use this several times for different exe files (read the
language specification at least once if needed)...
 
K

kimiraikkonen

Shorter way? Why the heck does that matter?

Anyways, you could do it in one giant, sloppy (imo), line:

Process.Run(Path.Combine(Application.StartupPath, "foo.exe"))

However, in my opinion being verbose is much better than trying to
make a "short" program. When you go to in to perform maintenance on
your code it is much more difficult to work with compact code.

Thanks,

Seth Rowe- Hide quoted text -

- Show quoted text -

Seth,
I understood and i agree that i don't like short coding but i want a
well-organized and well-understandable codings. That's why i asked the
shorter way meaning if there are alternative coding methods for
specifying root folder.

However look at this, there 2 problems:

1-I cannot hide my "foo.exe" while it's processing until it finishes,
it still present on the screen,
2-Between which lines should i put appstartup path for running
everyfolder where my project is installed?

Dim myProcess As System.Diagnostics.Process = New
System.Diagnostics.Process()
myProcess.StartInfo.WindowStyle =
System.Diagnostics.ProcessWindowStyle.Hidden
myProcess = System.Diagnostics.Process.Start("c:
\foo.exe")
myProcess.WaitForExit()
MsgBox(" Completed Successfully", MsgBoxStyle.Information,
"Completed")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top