# Solved: VB6 Shell command - BACKGROUND



## Hogskin (Apr 1, 2008)

I have an application in VB6 that triggers a .BAT file a couple times a minute using the SHELL command. The function is working fine. But a problem occurs when I am trying to perform other functions on that computer. (Some of my source code development is done on this computer.) When the COMMAND.COM box gets triggered, it wrests control from my other application momentarily, then returns it. This results in very problematic lost keystrokes.

Is there any way to keep the COMMAND.COM box from gaining foreground control? I have tried changing virtually all of the options on COMMAND.COM in the System32 directory with no success. I am hoping there may be a parameter for the SHELL command that can do this...

Alternately, if there is a way in XP to direct an application to grab control and not relinquish it to other tasks (without otherwise affecting execution of those other tasks), that would work for me.

This system is running Windows XP with SP2.

Thanks.


----------



## coderitr (Oct 12, 2003)

Use cmd.exe instead of command.com and in your Shell command, specify vbHide as the 2nd parameter. Command.com is a DOS emulator and works differently than cmd.exe which is a command interpreter. The vbHide as the 2nd parameter will keep the command prompt window from appearing.


----------



## Squashman (Apr 4, 2003)

If you have TweakUI installed there is an option in there for keeping applications from Stealing Focus. There is a registry change you can make as well to keep applications from stealing focus. But I am sure the code above will probably solve your issue as well.

http://www.onecomputerguy.com/windowsxp_tips.htm#focus


----------



## Hogskin (Apr 1, 2008)

Thanks VERY much, coderitr!!! The vbHide took care of it. Apparently the Shell command was already invoking cmd.exe, which I was unaware of. This is terrific after putting up with that aggravation and associated problems for over a year.


----------



## coderitr (Oct 12, 2003)

You're welcome. You can mark this thread as solved by clicking the red & white triangle. 

Welcome to TSG


----------



## cybertech (Apr 16, 2002)

coderitr said:


> You're welcome. You can mark this thread as solved by clicking the red & white triangle.
> 
> Welcome to TSG


Actually you mark it solved with the Thread Tools at the top of the page.


----------



## coderitr (Oct 12, 2003)

Oops. Sorry Cy.


----------



## cybertech (Apr 16, 2002)

No problem!


----------

