Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 28th, 2004, 04:03 PM
Registered User
 
Join Date: Nov 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Return information from cmd to VB

Do anyone know how to return information from a .cmd file, a return code and a message as an example, to VB after starting the .cmd file with the CreateProcessA api call?


 
Old November 30th, 2004, 04:53 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Have you looked at the SHELL command? Doesn't it give back a return value?

Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old November 30th, 2004, 06:32 PM
Registered User
 
Join Date: Nov 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Greg,
Thanks to your answer.
I find the Shell command not suited in my case. The Shell function runs other programs asynchronously, meaning I can risk having the next Vb statement executed before the Shell function is finished executing, as I understand. In my case I am starting a long running .cmd file with CreateProcessA. This lets me wait with the WaitForSingleObject until the shelled application is finished.
In .cmd files you can test for errorlevel. This is what I would like to pass back to VB together with a message text depending on where in the file errorlevel was raised.

 
Old November 30th, 2004, 08:30 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

After the wait for process termination using WaitForSingleObject, you can use GetExitCodeProcess to get the exit code:

http://support.microsoft.com/kb/q129796/

Marco
 
Old December 1st, 2004, 05:34 AM
Registered User
 
Join Date: Nov 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Marco,

Thanks for your advice. This will do.

Helge






Similar Threads
Thread Thread Starter Forum Replies Last Post
Open CMD, NSLookup, enter name, return IP mmcdonal VBScript 3 December 19th, 2006 08:40 AM
how to pass return value from Jscript to VB hertendreef ASP.NET 2.0 Professional 0 May 30th, 2006 11:01 AM
how to pass return value from Jscript to VB hertendreef VS.NET 2002/2003 0 May 30th, 2006 11:00 AM
How to get "SELECT COUNT(*)" return information? datagram ASP.NET 1.0 and 1.1 Basics 3 December 23rd, 2004 01:21 AM
return key based navigation VB 6.0 madhukp VB How-To 3 October 6th, 2004 04:32 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.