473,387 Members | 1,790 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,387 software developers and data experts.

Launching An External Program

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
8 2194
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
"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
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
"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
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
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
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: m11533 | last post by:
I am writing a fairly complex application in c# and Visual Studio .Net 2003. Right now I am working on a simple console application (to be launched in the future from a service) that receives...
4
by: dvestal | last post by:
How can I launch a .NET executable (a windows app written in VB.NET) from within another .NET assembly, and be able to tell when the user receives control? I could just kick it off with...
0
by: Scott Zabolotzky | last post by:
I'm using the following code to launch SIGNCODE.EXE to sign a CAB provisioning file from an ASP.NET app. When I run the code the exit code comes back as -1. I have not been able to determine what...
7
by: dhussong | last post by:
I have created a Setup and Deployment project in Visual Studio.NET 2003. After my installation has completed running I'd like to launch the EXE that I just installed. I've found how to launch the...
0
by: Jarrod Morrison | last post by:
Hi All Im a bit of a newbie to the .Net way of programming and am looking for a way to launch a program from a service program running on my winxp machine. I have tried a few methods but all...
1
by: FinallyInSeattle | last post by:
I need to be able to make a registry change (trust me, I don't like it either) and then launch an external .EXE from a small C# program. I've done a Process.Start, but when my program exits the...
2
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: ...
8
by: =?iso-8859-1?B?QW5kcuk=?= | last post by:
I would like to find out how I can launch an independent Python program from existing one in a cross-platform way. The result I am after is that a new terminal window should open (for io...
6
by: PsamtikNerd | last post by:
I need to know how to launch an external application using a parameter specified in my program. More specifically, the user enters a string, and my program will execute "cd <string>". Anyone know...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.