Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 28th, 2004, 04:03 PM
Registered User
 
Join Date: Nov 2003
Location: , , .
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?


Reply With Quote
  #2 (permalink)  
Old November 30th, 2004, 04:53 PM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
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
Reply With Quote
  #3 (permalink)  
Old November 30th, 2004, 06:32 PM
Registered User
 
Join Date: Nov 2003
Location: , , .
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.

Reply With Quote
  #4 (permalink)  
Old November 30th, 2004, 08:30 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Alameda, ca, USA.
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
Reply With Quote
  #5 (permalink)  
Old December 1st, 2004, 05:34 AM
Registered User
 
Join Date: Nov 2003
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Marco,

Thanks for your advice. This will do.

Helge

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 06:32 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.