473,387 Members | 1,812 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.

Running an executable from my .Net code

I am trying to find a way to run a .Net executable from within my vb.net
code. I need to pass parameters into the executable and wait for a return
and check the return value for an error before continuing.

Is this possible to do?

STom
Nov 21 '05 #1
7 6165
Hi,

Take a look at the process class's waitforexit method and process
startinfo.

http://msdn.microsoft.com/library/de...classtopic.asp

http://msdn.microsoft.com/library/de...rexittopic.asp

Ken
----------------------
"STom" <st***********@hotmail.com> wrote in message
news:en****************@TK2MSFTNGP12.phx.gbl...
I am trying to find a way to run a .Net executable from within my vb.net
code. I need to pass parameters into the executable and wait for a return
and check the return value for an error before continuing.

Is this possible to do?

STom

Nov 21 '05 #2
Hi,

Take a look at the process class's waitforexit method and process
startinfo.

http://msdn.microsoft.com/library/de...classtopic.asp

http://msdn.microsoft.com/library/de...rexittopic.asp

Ken
----------------------
"STom" <st***********@hotmail.com> wrote in message
news:en****************@TK2MSFTNGP12.phx.gbl...
I am trying to find a way to run a .Net executable from within my vb.net
code. I need to pass parameters into the executable and wait for a return
and check the return value for an error before continuing.

Is this possible to do?

STom

Nov 21 '05 #3
"STom" <st***********@hotmail.com> schrieb:
I am trying to find a way to run a .Net executable from within my vb.net
code. I need to pass parameters into the executable and wait for a return
and check the return value for an error before continuing.


\\\
Imports System.Diagnostics
..
..
..
Dim psi As New ProcessStartInfo()
With psi
.FileName = "foo.exe"
.Arguments = ...
End With
Dim p As Process = Process.Start(psi)
p.WaitForExit()
MsgBox(CStr(p.ExitCode))
///

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

Nov 21 '05 #4
"STom" <st***********@hotmail.com> schrieb:
I am trying to find a way to run a .Net executable from within my vb.net
code. I need to pass parameters into the executable and wait for a return
and check the return value for an error before continuing.


\\\
Imports System.Diagnostics
..
..
..
Dim psi As New ProcessStartInfo()
With psi
.FileName = "foo.exe"
.Arguments = ...
End With
Dim p As Process = Process.Start(psi)
p.WaitForExit()
MsgBox(CStr(p.ExitCode))
///

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

Nov 21 '05 #5
Herfried,

Thanks for your sample. Here are some other questions...

1. If I have 3 string arguments that I want to pass to the executable, with
the .Arguments, is the syntax like :
..Arguments = "one two three" ?

I will have these 3 arguments in string variables already within my coded.

2. Will the ExitCode be a numeric value that I can set within my executable
to return in case there is a failure or is it some generic error number?

Thanks again.

STom
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:e5**************@TK2MSFTNGP09.phx.gbl...
"STom" <st***********@hotmail.com> schrieb:
I am trying to find a way to run a .Net executable from within my vb.net
code. I need to pass parameters into the executable and wait for a return
and check the return value for an error before continuing.


\\\
Imports System.Diagnostics
.
.
.
Dim psi As New ProcessStartInfo()
With psi
.FileName = "foo.exe"
.Arguments = ...
End With
Dim p As Process = Process.Start(psi)
p.WaitForExit()
MsgBox(CStr(p.ExitCode))
///

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

Nov 21 '05 #6
"STom" <st***********@hotmail.com> schrieb:
1. If I have 3 string arguments that I want to pass to the executable,
with the .Arguments, is the syntax like :
.Arguments = "one two three" ?
Yes.
2. Will the ExitCode be a numeric value that I can set within my
executable to return in case there is a failure or is it some generic
error number?


You can return an integer value. You can make your 'Sub Main' a function
with 'Integer

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

Nov 21 '05 #7
Addendum:

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> schrieb:
You can return an integer value. You can make your 'Sub Main' a function
with...


.... 'Integer' return type and the use 'Return <return value>' to return a
certain value.

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

Nov 21 '05 #8

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

Similar topics

7
by: Johnny | last post by:
How do I create a link on a Web page on my hard drive that will run an executable file on my hard drive? For example, let's say I create runpoodle.htm and save it to my hard drive, and let's...
6
by: foldface | last post by:
Hi Sorry, don't know how to phrase the question any better. Within Visual Studio I have a style sheet that being dynamically added to the code, i.e. not via the html page. I want to place this...
0
by: WATYF | last post by:
This is my problem... I have some code that starts a Process and returns it to a variable... (prcBat) At any time while that process is running... I want to be able to Kill it by pressing a...
3
by: BobAchgill | last post by:
I am using FTP built in to my application to update the application and data from a server... What is the normal method folks use to over write the application while the program is active? What...
17
by: Csaba Gabor | last post by:
Is there a way to determine the path to the php executable (as opposed to the script. In other words, I am looking for the path to php.exe or php-win.exe) that is currently running (ie. how was...
9
by: Andrzej | last post by:
Greetings. Is there any project of universal environment for running programs written in C++ ? For example a programmer compiles program using compilator and linker that produces universal...
10
by: jon | last post by:
I am a beginner C programmer, this is actually my first programming lanugage, besides html, cgi, and javascript. I am looking for a way to make an .exe file, or a copy of my own file. I have tried...
4
by: njuneardave | last post by:
Hi, I have an application that will run a method depending on whether or not there is an instance of MS Word currently open. How do I determine whether or not an executable from another program...
2
by: NasirMunir | last post by:
I am trying to run an executable using shell. The executable look for certain files in the same directory and then run on those files. My problem: I have created a form which asks from the user to...
4
by: Brad Pears | last post by:
I have a vb.net 2005 project and have made a lot of modifications to it. The project runs fine in debug mode. Now I want to implement it and first I am running the executable on my machine to make...
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:
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.