Executing another application from one vb.net application

G

Guest

Hi All,

Would anybody be able to post me the command used in vb.net to execute an
application from within the current application?

Thanks.
kd
 
G

Guest

Thanks Ligthert.

The arguments for to execute my application contains a switch /S followed by
the argument. The following code however is failing.
Dim p As New Process
Dim pi As New ProcessStartInfo
pi.arguments = "/S testarg"
pi.FileName = "C:\Program files\MyApp\test.exe"
p.startinfo = pi
p.Start()

I am not sure if this is the correct way to pass multiple arguments!

Help is greatly appreciated.

kd
 
H

Herfried K. Wagner [MVP]

kd said:
Would anybody be able to post me the command used in vb.net to execute an
application from within the current application?

\\\
Imports System.Diagnostics
..
..
..
Process.Start("notepad", """C:\Bla Bla\1.txt""")
///

- or -

\\\
Shell("notepad ""C:\Bla Bla\1.txt""", AppWinStyle.NormalFocus)
///
 
C

Cor Ligthert

Kd,

You can always try this from the (DOSbox) commandline.
When it does it like that, than this would do it in my opinion as well as
you wrote it.

Cor
 
G

Guest

Cor,

The command runs successfully when executed from the command window. But
fails when executed through the vb.net code.

kd
 
C

Cor Ligthert

And what is the behaviour.

Did you try it with notepad in the same place?
(other arguments of course)

Cor
 
G

Guest

Cor,

Running notepad is working. Notepad.exe takes just one argument. So, does
IE. I was looking for any application that takes more than one argument,
along with switches, in order to test where the problem lies. If you do come
across any, please post it here, so that I can test it.

Regards.
kd.
 
C

Cor Ligthert

KD,

I checked it with this program and it did as expected.

\\\
Public Class KDtest
Public Shared Sub main(ByVal args() As String)
If args.Length > 0 Then
If args(0).ToUpper = "\S" Then
MessageBox.Show(args(1))
End If
Else
Dim p As New Process
Dim pi As New ProcessStartInfo
pi.Arguments = "\S Hello"
pi.FileName = "KD"
p.StartInfo = pi
p.Start()
End If
End Sub
End Class
///

I hope this helps?

Cor
 
H

Herfried K. Wagner [MVP]

kd said:
Running notepad is working. Notepad.exe takes just one argument. So, does
IE. I was looking for any application that takes more than one argument,
along with switches, in order to test where the problem lies. If you do
come
across any, please post it here, so that I can test it.

Depending on the application, certain parameter values need to be put
between double quotes, for example, file names containing space characters.
Maybe this is causing your problem.
 
G

Guest

The application is running successfully now.

Thanks Cor, your assistance was of great help.

kd.
 

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