473,626 Members | 3,265 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to catch the return code of one VB.Net executable from another VB.net executable

I have A.exe that should catch the return code of B.exe (both are written in VB.net) so A.exe can continue processing other commands. but A.exe cannot catch B's return code so an exception is not thrown as the program should. here's my code for A.exe

procEXE = Process.Start(P ROGRAM_NAME
procEXE.WaitFor Exit(

If procEXE.HasExit ed The
If procEXE.ExitCod e <> 0 The
Throw New Exception("Proc ess execution failed. Check the server and error logs for more details."
End I
End I

and here is the code for B.exe

Public Function Main(ByVal sArgs() As String) As Intege

Dim sNetUserId As Strin
Dim lReturnCode As Integer = -

Tr

sNetUserId = WindowsIdentity .GetCurrent().N ame(

If Not FunctionExecute Successful() Then Exit Functio
lReturnCode =

Catch Ex As Exceptio
HandleClientErr or(Ex

End Tr

Return lReturnCod

End Functio

Is there something wrong with what I did

thanks
libs
Nov 20 '05 #1
14 8787
Attach to the Exited event of the process.

"libs" <ld******@remov ethis.gapac.com > wrote in message
news:F8******** *************** ***********@mic rosoft.com...
I have A.exe that should catch the return code of B.exe (both are written in VB.net) so A.exe can continue processing other commands. but A.exe
cannot catch B's return code so an exception is not thrown as the program
should. here's my code for A.exe:
procEXE = Process.Start(P ROGRAM_NAME)
procEXE.WaitFor Exit()

If procEXE.HasExit ed Then
If procEXE.ExitCod e <> 0 Then
Throw New Exception("Proc ess execution failed. Check the server and error logs for more details.") End If
End If

and here is the code for B.exe:

Public Function Main(ByVal sArgs() As String) As Integer

Dim sNetUserId As String
Dim lReturnCode As Integer = -1

Try

sNetUserId = WindowsIdentity .GetCurrent().N ame()

If Not FunctionExecute Successful() Then Exit Function
lReturnCode = 0

Catch Ex As Exception
HandleClientErr or(Ex)

End Try

Return lReturnCode

End Function
Is there something wrong with what I did?

thanks,
libs

Nov 20 '05 #2
* "CJ Taylor" <[cege] at [tavayn] dit commmmm> scripsit:
Attach to the Exited event of the process.


Do you know why the OP's code doesn't work?

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3
Heh, didn't read the whole thing... just going for a fast response that I've
answered a couple times...

Man rough day for me in the Ng's.
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:c6******** ****@ID-208219.news.uni-berlin.de...
* "CJ Taylor" <[cege] at [tavayn] dit commmmm> scripsit:
Attach to the Exited event of the process.


Do you know why the OP's code doesn't work?

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #4
> Do you know why the OP's code doesn't work?

No And?

Cor
Nov 20 '05 #5
* "Cor Ligthert" <no**********@p lanet.nl> scripsit:
Do you know why the OP's code doesn't work?


No And?


Just a question.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #6
i tried that, and also set EnableRaisingEv ents to true. didnt work.

was there something wrong with the code? Will having a main() function with return value of integer would cause a return value be caught by ExitCode property?

----- CJ Taylor wrote: -----

Attach to the Exited event of the process.

"libs" <ld******@remov ethis.gapac.com > wrote in message
news:F8******** *************** ***********@mic rosoft.com...
I have A.exe that should catch the return code of B.exe (both are written in VB.net) so A.exe can continue processing other commands. but A.exe
cannot catch B's return code so an exception is not thrown as the program
should. here's my code for A.exe:
procEXE = Process.Start(P ROGRAM_NAME)

procEXE.WaitFor Exit()
If procEXE.HasExit ed Then

If procEXE.ExitCod e <> 0 Then
Throw New Exception("Proc ess execution failed. Check the server

and error logs for more details.") End If
End If
and here is the code for B.exe:
Public Function Main(ByVal sArgs() As String) As Integer
Dim sNetUserId As String

Dim lReturnCode As Integer = -1
Try
sNetUserId = WindowsIdentity .GetCurrent().N ame()
If Not FunctionExecute Successful() Then Exit Function

lReturnCode = 0
Catch Ex As Exception

HandleClientErr or(Ex)
End Try
Return lReturnCode
End Function
Is there something wrong with what I did?

thanks,

libs


Nov 20 '05 #7
That's all you got huh?

=)

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:c6******** ****@ID-208219.news.uni-berlin.de...
* "Cor Ligthert" <no**********@p lanet.nl> scripsit:
Do you know why the OP's code doesn't work?


No And?


Just a question.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #8
Where are you calling htis thing from?

"libs" <ld******@remov ethis.gapac.com > wrote in message
news:BC******** *************** ***********@mic rosoft.com...
i tried that, and also set EnableRaisingEv ents to true. didnt work.

was there something wrong with the code? Will having a main() function with return value of integer would cause a return value be caught by
ExitCode property?
----- CJ Taylor wrote: -----

Attach to the Exited event of the process.

"libs" <ld******@remov ethis.gapac.com > wrote in message
news:F8******** *************** ***********@mic rosoft.com...
> I have A.exe that should catch the return code of B.exe (both are written
in VB.net) so A.exe can continue processing other commands. but A.exe cannot catch B's return code so an exception is not thrown as the program should. here's my code for A.exe: >> procEXE = Process.Start(P ROGRAM_NAME) > procEXE.WaitFor Exit()
>> If procEXE.HasExit ed Then

> If procEXE.ExitCod e <> 0 Then
> Throw New Exception("Proc ess execution failed. Check the

server and error logs for more details.")
> End If
> End If
>> and here is the code for B.exe:
>> Public Function Main(ByVal sArgs() As String) As Integer
>> Dim sNetUserId As String

> Dim lReturnCode As Integer = -1
>> Try
>> sNetUserId = WindowsIdentity .GetCurrent().N ame()
>> If Not FunctionExecute Successful() Then Exit Function

> lReturnCode = 0
>> Catch Ex As Exception

> HandleClientErr or(Ex)
>> End Try
>> Return lReturnCode
>> End Function
>>> Is there something wrong with what I did?
>> thanks,

> libs


Nov 20 '05 #9
In article <F8************ *************** *******@microso ft.com>, libs wrote:
I have A.exe that should catch the return code of B.exe (both are written in VB.net) so A.exe can continue processing other commands. but A.exe cannot catch B's return code so an exception is not thrown as the program should. here's my code for A.exe:

procEXE = Process.Start(P ROGRAM_NAME)
procEXE.WaitFor Exit()

If procEXE.HasExit ed Then
If procEXE.ExitCod e <> 0 Then
Throw New Exception("Proc ess execution failed. Check the server and error logs for more details.")
End If
End If

and here is the code for B.exe:

Public Function Main(ByVal sArgs() As String) As Integer

Dim sNetUserId As String
Dim lReturnCode As Integer = -1

Try

sNetUserId = WindowsIdentity .GetCurrent().N ame()

If Not FunctionExecute Successful() Then Exit Function
lReturnCode = 0

Catch Ex As Exception
HandleClientErr or(Ex)

End Try

Return lReturnCode

End Function
Is there something wrong with what I did?

thanks,
libs


Are these window apps or console apps?

--
Tom Shelton [MVP]
Nov 20 '05 #10

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

Similar topics

6
8834
by: Sunny | last post by:
Hi, I have a very serious issue at hand. I have created a small C# Console App (Csd.exe) that collects a list of files as its argument and generates their Md5 sets. This application is used by other applications in my dept, which simply call this Csd.exe app and passing a list of files. I want to ask how can I return a value from this Csd.exe application as an indicator or a signal to the calling app that Csd.exe has finished working....
6
5042
by: Martin Ortiz | last post by:
Which is best approach? Should Try + Catch be used to only deal with "catastrophic" events (like divide by zero, non-existant file, etc...etc...) Or should Try + Catch be used IN PLACE of regular defensive programming? (ie if file exists do this, if not do something else) Or should Try + Catch be used TO SUPPLAMENT regular defensive programming?
18
2879
by: Simon | last post by:
I was of the impression that code placed after a Try...Catch block was only executed if there was no exception thrown. I've got some VB.net code as part of a Windows form that executes even when an exception is thrown - it behaves as if the code is part of a finally block. Looking through all the documentation and MSDN articles, it seems that none of the examples contain code placed
13
1573
by: Woody Splawn | last post by:
I have a try catch statement in a fucntion that is supposed to return a true or a false My code looks like this: Try mySqlConnection.Open() Dim Da1 As New SqlDataAdapter("Select JnlType, Description from JnlType", mySqlConnection) Dim Ds As New DataSet("X")
20
1362
by: Woody Splawn | last post by:
In a message yesterday titled Try Catch Question I got numerous responses. Thank you to all. After all the smoke clears I guess the question is where to place the Return True statement in the block of code below that is part of a function. Should it be at the end of the try block, as dipicted below, or should it be after the End Try Block? Or does it make a difference? Try mySqlConnection.Open() Dim Da1 As New SqlDataAdapter("Select...
2
1915
by: CodeSlayer | last post by:
Hi all, This one really has me and the other .Net developers at my work stumped. I have an application that is doing the following: 1 - attempt to validate that user can create a windows task via COM interops 2 - an exception is thrown because user doesn't exist 3 - Exception is caught by calling code shown below:
34
2963
by: priyanka | last post by:
Hi, I was wondering if we could parse or do something in the executable( whose source language was C). How can I use some scripting language like perl/python to find out the information about the executable ? Is it possible ? Also, how does the compiler add inling to the program ? I know that whenever it sees"inline" in front of the procedure name, it inlines it. But if we give the -finline options, it inline all the procedures ? How
7
6487
by: Rob R. Ainscough | last post by:
In VB6 I can use Resume Next to execute the line of coding following the line that cause an exception. There doesn't appear to be anything similiar when using Try...Catch -- so how can one resume the next statement when an error can be ignored? Thanks, Rob.
0
8196
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8637
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8364
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5574
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4092
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4197
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2625
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1808
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1511
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.