Question running a.exe program from the command prompt

taggart

Member
Joined
Nov 2, 2015
Messages
10
Programming Experience
10+
Hello forum

Is there a way in vb to make the prog wait before returning control to the calling prog until its completed its processing?

When I run my vb.net program from the command prompt, the cursor returns immediately before the program has finished processing its stuff. The program does its stuff correctly and finishes a second or two later (tested by displaying an msgbox at towards the end of the prog)

I want to run this prog from a third party piece of software code which will call my program. I need the code to wait for my program to finish before proceeding to the subsequent code as it processes the output of my prog. At the moment its trying to process before my prog has finished.

Is there a way in vb to make the prog wait before returning control to the calling prog until its completed its processing?
 
Alternatively, this could work.

VB.NET:
        For Each proc As Process In Process.GetProcesses
            If proc.ProcessName.Contains("cmd") Then
                MsgBox(proc.ProcessName)
            End If
        Next

If you had multiple command line processes running, it might be harder to detect which is which. Unless you can start a process under a custom friendly name, or get the process ID when it's started.
 
Thanks for the suggestions. Much appreciated.
As soon as my program is called by the third party code (which i dont have access to) control is passed back to the calling prog (third party code) to continue its processing before my program has finished doing its thing. It seems nothing that i put in my code can stop this happening.
I have suggested that the third party call my program using the Start /Wait programname construct from their shell command. This seems to work.
 
When I run my vb.net program from the command prompt, the cursor returns immediately before the program has finished processing its stuff. The program does its stuff correctly and finishes a second or two later (tested by displaying an msgbox at towards the end of the prog)
I misunderstood and thought you were calling other program, but what you say here don't make sense. If your app is a console application, then cursor can't return until your app has exited and therefore have completed all its processing. If your app is not a console application, then why call it from shell? A GUI application called from shell will just start it as a new process and return cursor immediately. As you describe your app doing a few seconds processing and then closing, maybe your app should be a console application instead?
 
In that case you are right. It should be a console app. I wasn't aware that a console app functioned in the way you describe.

My vb app is a GUI app with no GUI functionality ie it uses myappliation_startup event to do its processing and quit before any form is loaded. Given your reply, this would explain the immediate return of control to the calling program (a 4gl database language).

Having said all that, the solution I posted previously is working fine, although i admit, its not the most elegant solution.

thanks for your information.
 
Back
Top