Hi,
I'm a mechanical engineer new to programming. I was trying to write a
program in Visual Basic Express Edition 2005. I want to run a file
using an application called madymo601 in command prompt.

Normally what I do is to go to Start> Run> and type cmd /k madymo601 c:
\filename.xml . I have put the /k there as i need the cmd window open
after execution to view the results. I tried to make a small VB
program to avoid typing in the commands since the .xml files I need to
run could be in various locations. I wrote a code as given below. But
seems to have something wrong with the diagnostics.process.start line.


Private Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
OpenFileDialog1.Title = "Please select .xml file"
OpenFileDialog1.Filter = "xml files|*.xml"
OpenFileDialog1.ShowDialog()
If OpenFileDialog1.FileName <> "" Then

TextBox1.Text = (OpenFileDialog1.FileName)
End If
End Sub

Private Sub Button2_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim filepath As String = (TextBox1.Text)

Diagnostics.Process.Start("cmd /k madymo601", filepath)
End Sub

Hope someone could help me out with the right way to do this.
Thanx.

Re: How to use VB Express to run a program through command prompt by kimiraikkonen

kimiraikkonen
Sat May 10 16:03:23 CDT 2008

On May 10, 11:17 pm, Sooraj <soorajgopin...@gmail.com> wrote:
> Hi,
> I'm a mechanical engineer new to programming. I was trying to write a
> program in Visual Basic Express Edition 2005. I want to run a file
> using an application called madymo601 in command prompt.
>
> Normally what I do is to go to Start> Run> and type cmd /k madymo601 c:
> \filename.xml . I have put the /k there as i need the cmd window open
> after execution to view the results. I tried to make a small VB
> program to avoid typing in the commands since the .xml files I need to
> run could be in various locations. I wrote a code as given below. But
> seems to have something wrong with the diagnostics.process.start line.
>
> Private Sub Button1_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> OpenFileDialog1.Title =3D "Please select .xml file"
> OpenFileDialog1.Filter =3D "xml files|*.xml"
> OpenFileDialog1.ShowDialog()
> If OpenFileDialog1.FileName <> "" Then
>
> TextBox1.Text =3D (OpenFileDialog1.FileName)
> End If
> End Sub
>
> Private Sub Button2_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Button2.Click
> Dim filepath As String =3D (TextBox1.Text)
>
> Diagnostics.Process.Start("cmd /k madymo601", filepath)
> End Sub
>
> Hope someone could help me out with the right way to do this.
> Thanx.

Hi Sooraj,
To use Command prompt, you'd better use Shell instead of Process
class[Process class wants exact path of cmd.exe(c:\windows
\system32\cmd.exe..... unlike Shell)].

So, it would be like this:
Shell("cmd /k madymo601 filepath",AppWinStyle.NormalFocus)

And make sure you include exact path of your application to launch. I
mean, for example if you application (madymo601) resides as c:
\madymo601.exe then you should use:

Shell("cmd /k c:\madymo601 filepath",AppWinStyle.NormalFocus)

Hope this helps,

Onur G=FCzel

Re: How to use VB Express to run a program through command prompt by kimiraikkonen

kimiraikkonen
Sat May 10 16:07:37 CDT 2008

On May 11, 12:03 am, kimiraikkonen <kimiraikkone...@gmail.com> wrote:
> On May 10, 11:17 pm, Sooraj <soorajgopin...@gmail.com> wrote:
>
>
>
> > Hi,
> > I'm a mechanical engineer new to programming. I was trying to write a
> > program in Visual Basic Express Edition 2005. I want to run a file
> > using an application called madymo601 in command prompt.
>
> > Normally what I do is to go to Start> Run> and type cmd /k madymo601 c:
> > \filename.xml . I have put the /k there as i need the cmd window open
> > after execution to view the results. I tried to make a small VB
> > program to avoid typing in the commands since the .xml files I need to
> > run could be in various locations. I wrote a code as given below. But
> > seems to have something wrong with the diagnostics.process.start line.
>
> > Private Sub Button1_Click(ByVal sender As Object, ByVal e As
> > System.EventArgs) Handles Button1.Click
> > OpenFileDialog1.Title =3D "Please select .xml file"
> > OpenFileDialog1.Filter =3D "xml files|*.xml"
> > OpenFileDialog1.ShowDialog()
> > If OpenFileDialog1.FileName <> "" Then
>
> > TextBox1.Text =3D (OpenFileDialog1.FileName)
> > End If
> > End Sub
>
> > Private Sub Button2_Click(ByVal sender As Object, ByVal e As
> > System.EventArgs) Handles Button2.Click
> > Dim filepath As String =3D (TextBox1.Text)
>
> > Diagnostics.Process.Start("cmd /k madymo601", filepath)
> > End Sub
>
> > Hope someone could help me out with the right way to do this.
> > Thanx.
>
> Hi Sooraj,
> To use Command prompt, you'd better use Shell instead of Process
> class[Process class wants exact path of cmd.exe(c:\windows
> \system32\cmd.exe..... unlike Shell)].
>
> So, it would be like this:
> Shell("cmd /k madymo601 filepath",AppWinStyle.NormalFocus)
>
> And make sure you include exact path of your application to launch. I
> mean, for example if you application (madymo601) resides as c:
> \madymo601.exe then you should use:
>
> Shell("cmd /k c:\madymo601 filepath",AppWinStyle.NormalFocus)
>
> Hope this helps,
>
> Onur G=FCzel

Correcting my last post, you should use:(just added missing .exe
extension which you may not need)
Shell("cmd /k c:\madymo601.exe filepath",AppWinStyle.NormalFocus)

for the assumption above.

Onur

RE: How to use VB Express to run a program through command prompt inte by FamilyTreeMike

FamilyTreeMike
Sat May 10 16:30:00 CDT 2008

Process takes a file to execute in the call you are using. You are passing
the entire command line, which is why it did not work.

If I were youI would do it as follows:

Dim p As New Process
p.StartInfo.FileName = "cmd"
p.StartInfo.Arguments = "/k madymo601 TheInputFile"
Process.Start


"Sooraj" wrote:

>
> Hi,
> I'm a mechanical engineer new to programming. I was trying to write a
> program in Visual Basic Express Edition 2005. I want to run a file
> using an application called madymo601 in command prompt.
>
> Normally what I do is to go to Start> Run> and type cmd /k madymo601 c:
> \filename.xml . I have put the /k there as i need the cmd window open
> after execution to view the results. I tried to make a small VB
> program to avoid typing in the commands since the .xml files I need to
> run could be in various locations. I wrote a code as given below. But
> seems to have something wrong with the diagnostics.process.start line.
>
>
> Private Sub Button1_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> OpenFileDialog1.Title = "Please select .xml file"
> OpenFileDialog1.Filter = "xml files|*.xml"
> OpenFileDialog1.ShowDialog()
> If OpenFileDialog1.FileName <> "" Then
>
> TextBox1.Text = (OpenFileDialog1.FileName)
> End If
> End Sub
>
> Private Sub Button2_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Button2.Click
> Dim filepath As String = (TextBox1.Text)
>
> Diagnostics.Process.Start("cmd /k madymo601", filepath)
> End Sub
>
> Hope someone could help me out with the right way to do this.
> Thanx.
>