Current location: Hot Scripts Forums » Programming Languages » Visual Basic » Executing VB6 app using a batch file


Executing VB6 app using a batch file

Reply
  #1 (permalink)  
Old 09-06-06, 04:49 AM
dekra's Avatar
dekra dekra is offline
Newbie Coder
 
Join Date: Jul 2005
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Executing VB6 app using a batch file

I need your help!!!!

I want to execute my VB6 application using a batch file (*.bat)... I have already achived this, but I need to throw back a return/error variable back to the batch file... Is this possible?

Ex. (Batch file)

x = VB6app.exe

How can I throw the return value back to x from my VB6 app?

Thanks!
Reply With Quote
  #2 (permalink)  
Old 09-19-06, 05:21 AM
DougT DougT is offline
New Member
 
Join Date: Sep 2006
Location: Maldon. Essex, UK
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Hi,

You can use a couple of APIs to set a return code from your Progam:
The following statements go into the Declarations section:
Code:
Private Declare Function TerminateProcess Lib "kernel32" _
                (ByVal hProcess As Long, _
                 ByVal uExitCode As Long) As Long

Declare Function GetCurrentProcess Lib "kernel32" () As Long
Then, when you exit your Program;
Code:
lngprocess = GetCurrentProcess
lngReturn = TerminateProcess(lngprocess, lngReturnCode)
Where lngReturn, lngprocess and lngReturncode are of type Long
You should set lngReturnCode to the value you wish to be passed back to the .bat file.
The Variable ERRORLEVEL within the .bat file will be set to the value of lngReturnCode when the program terminates.

Example .bat file:
Code:
@echo off
MyProg.exe  
if ERRORLEVEL 4 echo Error 4
This executes the program called MyProg.exe and if it sets the return code to 4 a message "Error 4" is displayed.

Regards
Doug
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Form to Text File Justin171985 PHP 14 02-09-11 11:55 AM
Checking a file exists lee PHP 3 04-23-06 12:44 AM
Error message not getting displayed. sanjeet Windows .NET Programming 0 12-20-05 10:48 AM
Batch 'ping' process with results sent to a file search66 Visual Basic 0 10-06-05 09:58 AM
Upload file to table so ONLY files tied to primary key are displayed in record? grafixDummy PHP 4 12-20-03 04:28 PM


All times are GMT -5. The time now is 01:17 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.