By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,185 Members | 1,271 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,185 IT Pros & Developers. It's quick & easy.

Launching An External Program

P: n/a
I am trying to launch an external program within Visual Basic 2005 Express.
If it is a simple program it works well with:-

myProg = "C:\MyFolder\MyApp.exe"
System.Diagnostics.Process.Start(myProg)

However, the application in question needs various command line arguments
added when it is launched, such as:-

"C:\MyFolder\MyApp.exe -h 9 -r 55 -j testfile.abc"

When I try this a Win32Exception was handled because it says it cannot find
the file specified. I am sure the problem is in how the arguments are
handled. Any ideas please?

Nov 21 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Keith French wrote:
I am trying to launch an external program within Visual Basic 2005 Express.
If it is a simple program it works well with:-

myProg = "C:\MyFolder\MyApp.exe"
System.Diagnostics.Process.Start(myProg)

However, the application in question needs various command line arguments
added when it is launched, such as:-

"C:\MyFolder\MyApp.exe -h 9 -r 55 -j testfile.abc"

When I try this a Win32Exception was handled because it says it cannot find
the file specified. I am sure the problem is in how the arguments are
handled. Any ideas please?


Are you just changing your myProg string to include MyApp's arguments?

Have you tried setting the arguments with Process's 'startInfo.Arguments'?

Nov 21 '05 #2

P: n/a
"Keith French" <ke*********@btconnect.com> schrieb:
I am trying to launch an external program within Visual Basic 2005 Express.
If it is a simple program it works well with:-

myProg = "C:\MyFolder\MyApp.exe"
System.Diagnostics.Process.Start(myProg)

However, the application in question needs various command line arguments
added when it is launched, such as:-

"C:\MyFolder\MyApp.exe -h 9 -r 55 -j testfile.abc"

Check out 'Process.Start(<file name>, <arguments>)'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3

P: n/a
No I haven't tried that. Can you give me the syntax or point me to a good
web reference please?
"beaker" <bl******@rhubarbrhubarbblahblah.net> wrote in message
news:en**************@tk2msftngp13.phx.gbl...
Keith French wrote:
I am trying to launch an external program within Visual Basic 2005
Express. If it is a simple program it works well with:-

myProg = "C:\MyFolder\MyApp.exe"
System.Diagnostics.Process.Start(myProg)

However, the application in question needs various command line arguments
added when it is launched, such as:-

"C:\MyFolder\MyApp.exe -h 9 -r 55 -j testfile.abc"

When I try this a Win32Exception was handled because it says it cannot
find the file specified. I am sure the problem is in how the arguments
are handled. Any ideas please?


Are you just changing your myProg string to include MyApp's arguments?

Have you tried setting the arguments with Process's 'startInfo.Arguments'?

Nov 21 '05 #4

P: n/a
"Keith French" <ke*********@btconnect.com> schrieb:
No I haven't tried that. Can you give me the syntax or point me to a good
web reference please?


..NET Framework Class Library -- 'ProcessStartInfo' Class
<URL:http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemdiagnosticsprocessstartinfoclasstopic.a sp>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #5

P: n/a
Thanks for that it now handles the arguments fine using:-

'Process.Start(<file name>, <arguments>)

However, the program I am launching is a DOS program and you stop its
display with CTRL-C, which works, the problem is this also closes the
command prompt window it runs it. I need to see some output of the results
of this program and hence need to keep the window open.

Is there a way of doing this as well?
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:Og**************@TK2MSFTNGP14.phx.gbl...
"Keith French" <ke*********@btconnect.com> schrieb:
I am trying to launch an external program within Visual Basic 2005
Express. If it is a simple program it works well with:-

myProg = "C:\MyFolder\MyApp.exe"
System.Diagnostics.Process.Start(myProg)

However, the application in question needs various command line arguments
added when it is launched, such as:-

"C:\MyFolder\MyApp.exe -h 9 -r 55 -j testfile.abc"

Check out 'Process.Start(<file name>, <arguments>)'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #6

P: n/a
Keith,

"Keith French" <ke*********@btconnect.com> schrieb:
However, the program I am launching is a DOS program and you stop its
display with CTRL-C, which works, the problem is this also closes the
command prompt window it runs it. I need to see some output of the results
of this program and hence need to keep the window open.


You could redirect the application's output:

<URL:http://dotnet.mvps.org/dotnet/samples/misc/RedirectConsole.zip>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #7

P: n/a
Thanks for that it works now. The only thing is that I have to terminate my
DOS program with CTRL-C, which should just stop it running and not close the
window. This way you can read the results from its run. Is there a way to
keep the window open? What about running "cmd.exe" as the program and my
program as arguments off of CMD.exe?

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:Og**************@TK2MSFTNGP14.phx.gbl...
"Keith French" <ke*********@btconnect.com> schrieb:
I am trying to launch an external program within Visual Basic 2005
Express. If it is a simple program it works well with:-

myProg = "C:\MyFolder\MyApp.exe"
System.Diagnostics.Process.Start(myProg)

However, the application in question needs various command line arguments
added when it is launched, such as:-

"C:\MyFolder\MyApp.exe -h 9 -r 55 -j testfile.abc"

Check out 'Process.Start(<file name>, <arguments>)'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #8

P: n/a
"Keith French" <ke*********@btconnect.com> schrieb:
Thanks for that it works now. The only thing is that I have to terminate
my DOS program with CTRL-C, which should just stop it running and not
close the window. This way you can read the results from its run. Is there
a way to keep the window open?
I don't know if this is possible, but I assume it's not.
What about running "cmd.exe" as the program and my program as arguments
off of CMD.exe?


"cmd.exe" doesn't expect a file to run as parameter, IIRC. However, you
could create a batch file which starts the executable and then uses 'PAUSE'
to keep the console open.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.