tags:

views:

666

answers:

4

How to bring CMD.EXE window to top? (I would prefer a command or script without a need to compile anything).

+1  A: 

Not sure there is any 'out of the box' functionality that will do that, but there are a few products: Console Windows Tweaks

SomeMiscGuy
Thanks for the link.
Shoban
+1  A: 

Your question is extremely vague.

It sounds like you're asking for "alt+tab".

dss539
Vote up for the sense of humor
agsamek
Well thanks, but I seriously didn't understand what you were asking. Now I understand that you wanted a way to "set window focus using a script". You might want to change your question tags to "scripting windows". Your question isn't really specific to the command shell. I'm glad that someone was able to give you a useful answer, though. :)
dss539
A: 

With compiling:

Easy, just use Win32 API to FindWindow according to its title or class and then send it a message or bring it to the front.

Without compiling:

I'd suggest you'd find a command line utility that can do the equivalent of FindWindow and SetForgroundWindow, so you could call it from a batch file or any other script.

Assaf Lavie
+2  A: 

The Wscript.Shell object accessible from Windows Script Host (either VBS or JS) has a method called "AppActivate" which, when passed a window title, will attempt to "activate" (which may bring it to the foreground if it's not minimised).

The following code snippet in VBScript worked on my machine:

Set WShell = CreateObject("WScript.Shell")
WShell.AppActivate "Command Prompt"

(Edited: Initially I hadn't tried it. Then I did)

Jason Musgrove