Set windows focus from DOS

I have a continuously-running DOS application on an unattended Win95 station. This DOS app MUST have focus for optimum performance. It runs as an app server, polling a queue looking for batch files to execute. Some of those batch files may launch windows apps (which spawn in their own windows, of course) and THOSE apps have splash screens which grab focus, no matter what shortcut or "start /m" settings you use. (The EGO of these people!)

This puts the app server into the background.

What I would like is a command line utility that can switch focus BACK to the app server. I would put it at the end of batch files being executed, forcing Windows to put the app server in the foreground. Given the complexity of Windows processes, etc. I would imagine that the utility would take the app server's windows title as the parameter...

Has anyone written such a beast?


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

There's a freeware utility called AutoIt that works for me. It's hard to use because you have to learn the script language, but in your case:

WinActivate, Command Prompt

is the entire script. The script can then be converted to an executable and called from the command line. There are many other uses for this handy util that will allow you to control the windows side from DOS. Get it here:


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Hi CrashAlpha,

You can also do this using VBScript:
set WshShell = CreateObject("WScript.Shell")
WshShell.AppActivate "App Title"

Put that in a file called "Whatever.VBS" then run it from your batchfile using:

Hi Pasha,

Recommend points split between easoccer and pbarrette (me).

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft DOS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.