views:

498

answers:

3

I have a console application (written in VB6 ) which is behaving strangely on my machine. I kick it off from the command line and what should be a two minute job drops straight back to the prompt - if I run this on another machine the executable will sit and wait until the job finishes before returning control back to the prompt. If I check process explorer I can see that the executable is running as a background process and other than this strange background-ness is running as expected.

Any thoughts on why this could be happening? (Running on 32-bit Windows XP Pro SP3.)

A: 

Sounds like an error is occurring that is being 'swallowed' by the application. Do you have the source code?

Errors in VB6 apps are often due to some COM component not installed and/or registered.

Download SysInternals Process Monitor and this will show up accesses to ProgIDs that fail (uninstalled/unregistered COM components).

Check out: Process Monitor - Hands-On Labs and Examples.

Have you checked permissions? Is the application accessing any network based resources?

Mitch Wheat
have looked at it with procmon, there do not appear to be any egregious errors. The first few events are "Process Start", "Thread Create", then it starts "LoadImage" for the executable (.exe) and for ntdll.dll, then the prefetch file is read, then it starts querying some directories (c:\program files\, c:\windows) until it starts loading dlls. Interestingly it also loads the dll's from google desktop and my media player (called media monkey)... but as far as I can see no real errors.
Jamie Cook
I should also note that the program does work correctly... it's not meant to generate any output at the command prompt... I just want the command prompt to wait for it to finish processing so that the next step in my process can access the files generated by the executable (accessing these files while the executable is running in the background and potentially writing these files isn't likely to be a winning move)
Jamie Cook
Application is not using network based resources.
Jamie Cook
i've got a quick capture of hte procmon output here http://img8.imageshack.us/img8/2670/ptassignprocmonevents.png
Jamie Cook
Could be nothing, but all those Name Not Found entries might be worth running down.
Oorang
How about taking a snapshot of Process Monitor output on the Machine that works and comparing to the output from the one that doesn't?
Mitch Wheat
A: 

It sounds to me as though the app isn't being recognised as a console app on one of your machines. Console apps weren't officially supported in VB6, although there are some well-known hacks for creating them (particularly the free add-in vbAdvance). Possibly your console app is a bit unreliable? If Windows thinks your app is a GUI rather than a console app, it won't wait for it to finish.

As a pragmatic workaround: try launching with start /wait rather than just using the exename. That forces the command prompt to wait for the program to finish, whether it's a GUI app or a console app.

MarkJ
Start wait does the trick nicely! I think that sounds like the most likely explanation as well, I've got the source code but I've very studiously avoided getting involved as I don't want to be tainted by the VB6-ness of it.
Jamie Cook
+2  A: 

It's totally unclear whether this is an application you wrote and have the source code for. If that's the case, you need to get in and start debugging. At the least, use OutputDebugString to send information about what's going on to any number of potential viewers. Taking that a step further, consider rewiring the app using the Console module I wrote, along with vbAdvance to recompile. This combination will allow you the full power of the VB6 IDE to debug within. No more guessing about what's going on.

Then again, if it's not your app, I'm not sure what VB6 has to do with it and wish you the best of luck trying to figure out what's up.

Karl E. Peterson
+1 The comment on my answer indicates Jamie does have the source code, but is a bit allergic to it :)
MarkJ
C'mon Jamie, you'll only get cooties if you kiss it on the mouth! Sheesh... Ah well.
Karl E. Peterson