|
-
September 15th, 1999, 04:14 PM
#1
Making VB app. return exit code
I am executing a VB program as a Part of SQL server Job and wants it to return exit code telling its success and failure based on which it can make further decision.
-
September 16th, 1999, 01:41 AM
#2
Re: Making VB app. return exit code
if you end your VB program via ExitProcess API you can specify a "return code", that can be trapped by a calling process.
-
September 16th, 1999, 10:24 AM
#3
Re: Making VB app. return exit code
Thanks a lot Lothar ,You make it sound possible and easy.I am completely trapped into doing this.
Can I request you to explain it a little more.Will the return value of this API cCall EXIT PROCESS serve as exit code?
Thanks in advance
-
September 16th, 1999, 10:38 AM
#4
Re: Making VB app. return exit code
Hi Tina,
let's assume your VB app looks like this:
declaration for ExitProcess goes here (from API-Addin)
Sub Main
Call ExitProcess(1)
End Sub
Then, e.g. in an NT Commandfile
yourprogram.exe
if errorlevel 1 goto error
goto ok
:error
program failed
k
See what I mean? You can query the argument to ExitProcess in a command file via ERRORLEVEL or in another process via GetExitCodeProcess API.
I am not sure if it is smart to end a VB program with ExitProcess.
It might cause problems with unreleased resources.
If does work, though as far as returning an exit code is concerned.
-
September 16th, 1999, 11:16 AM
#5
Re: Making VB app. return exit code
here's a complete sample tested in NT 4
option Explicit
private Declare Sub ExitProcess Lib "kernel32" (byval uExitCode as Long)
Sub Main()
ExitProcess 5
End Sub
Make exe: c:\project1.exe
the command file
@echo off
c:\project1.exe
if errorlevel 5 goto error
goto ok
:error
@echo error
k
play around with the exitprocess statement: set it's argument to 5 or zero and see what happens in the commandfile!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|