Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Set windows focus from DOS

Posted on 2003-03-13
Medium Priority
Last Modified: 2006-11-17
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?


Question by:CrashAlpha
  • 2

Accepted Solution

easoccer earned 160 total points
ID: 8130898
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:


LVL 10

Assisted Solution

pbarrette earned 140 total points
ID: 8135038
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:

LVL 10

Expert Comment

ID: 9635522
Hi Pasha,

Recommend points split between easoccer and pbarrette (me).


Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question