473,383 Members | 1,717 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

How to use VB Express to run a program through command promptinterface?


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 StartRunand 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.
Jun 27 '08 #1
3 1595
On May 10, 11:17 pm, Sooraj <soorajgopin...@gmail.comwrote:
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 StartRunand 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.
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üzel
Jun 27 '08 #2
On May 11, 12:03 am, kimiraikkonen <kimiraikkone...@gmail.comwrote:
On May 10, 11:17 pm, Sooraj <soorajgopin...@gmail.comwrote:
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 StartRunand 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.

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üzel
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
Jun 27 '08 #3
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 StartRunand 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.
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: garyusenet | last post by:
Hi I'm playing around with the main method signature, and testing reading of command line paramaters. At the moment i have to build the solution, go to a command prompt, navigate to the folder,...
4
by: talkingpidgin | last post by:
I am trying to compile my first windows program using microsoft visuall c++ express. It is a command line program that must run completely isolated without any setup. It's not a large or...
7
by: Miro | last post by:
I think i have found my problem following an example ive searched for on the net. I am using vb.net 2005 express. What I am looking for is a drag drop from the toolbar that is an...
12
by: Light | last post by:
Hi all, I posted this question in the sqlserver.newusers group but I am not getting any response there so I am going to try it on the fine folks here:). I inherited some legacy ASP codes in my...
3
by: Steve | last post by:
Hi All I downloaded Sql server 2005 express SP2 and attempted to modify the Bootstrapper package files as I did with SP1 When i try to install SQL server as part of my VS 2005 deployment app I...
4
by: Amber | last post by:
The installer tells it faild to config db2inst1, the db2setup.err is as following: /usr/share/themes/Clearlooks/gtk-2.0/gtkrc:60: Engine "clearlooks" is unsupporte d, ignoring Jun 15, 2007...
1
by: gimme_this_gimme_that | last post by:
Hello, Looking back on it - knowing what I know now - I should have run setup.exe by right clicking and explicitly running as an Administrator. Well, here I am. I installed DB2 Express-C from...
6
by: =?Utf-8?B?cGNuZXJk?= | last post by:
I know that VB installs version 3.5 of .Net. I have versions 1.1 & 2.0 on my PC. Can I uninstall versions 1.1 & 2.0 after I install VB? I've been browsing thru books on VB Express Edition. In one...
2
by: Carlton Kirby | last post by:
I need to execute a job on a SQL Express 2005 instance (no SQLAgent). The job will be executed manually by a user, so it doesn't need to be scheduled to run automatically. I thought I could...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.