Make an active batch file window visible after starting browser

I've got a batch file that handles an installation for clients. At one point it opens a browser window and later requires input; i.e.
download file
move file
start instructions.htm
Choice /c yn
continue installation
start thankyou.htm
exit

The problem is that instructions.htm covers up the command window and a novice user would never notice. I need the batch process to pop back so that it is layered over the top of the browser window. I thought that start /wait would do it but not so. Any suggestions?
ProTek2Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
sjklein42Connect With a Mentor Commented:
Fixed to use %TEMP% to point to the temp file folder instead of hard-coded folder.

title ThisIsMyWindow
echo set WSHShell = WScript.CreateObject("WScript.Shell") > "%TEMP%\AppAct.VBS"
echo WSHShell.Appactivate "ThisIsMyWindow" >> "%TEMP%\AppAct.VBS"
start CScript "%TEMP%\AppAct.VBS"

Open in new window

0
 
markdormerCommented:
If you call a vbscript file that contains this code it will give the focus to the batch file Window.

    set WshShell = WScript.CreateObject("WScript.Shell")
         WshShell.AppActivate "Command Prompt"
0
 
Psy053Connect With a Mentor Commented:
In your batch file, you could include the following lines:

What it does it creates a VBS File, and then runs it.

The VBS file uses the AppActivate Method to bring the Command Prompt window to the front.
echo set WSHShell = WScript.CreateObject("WScript.Shell") > "C:\Data\Scripts\CMD_Scripts\AppAct.VBS"
echo WSHShell.Appactivate "C:\Windows\system32\cmd.exe" >> "C:\Data\Scripts\CMD_Scripts\AppAct.VBS"
CScript "C:\Data\Scripts\CMD_Scripts\AppAct.VBS"

Open in new window

0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
ProTek2Author Commented:
Thank you both for such quick, clear responses. With only 2 minutes separating them, I'm going to split the points. Wish I had 500 for each of you.

Bottom line here is that this ole dog (started in the early 60s) needs to update his scripting tool skills. Thanks for the boot in that direction.
0
 
ProTek2Author Commented:
Well it looks like I got reminded that assuming is a bad idea. I ass-u-me d that the solutions would work but it turns out they don't.

I now appreciate the need to further my scripting skills even more. :-)
0
 
ProTek2Author Commented:
No thank you. The solutions offered failed in the same way that my previous countless attempts did. I'm approaching the whole script with vbs which I think will work and will ask another question when I've learned more about it.
0
 
ProTek2Author Commented:
If you, or someone else, actually knows of a solution, by all means... reopen the question. Like both of the earlier responders, I thought that making the window active would bring it to the front but that is not the case, no matter how you do it. So let's revisit it.
0
 
sjklein42Commented:
I don't have a solution (yet) to this interesting problem, but the approach I am investigating is to make the window "Always-on-Top" instead of trying to "raise" it.  There does not appear to be a programmatic way to "raise" a window, but there are several utilities out there that are able to make a window become an "Alway-On-Top" window.  If anyone know how to do that from a program, speak up!
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
We use the powerful and free cmdow.exe (www.commandline.co.uk/cmdow) to manipulate existing windows, e.g. resize or bring to front.
0
 
ProTek2Author Commented:
Because this is an install routine that has to run for novice users on XP - Win7, it has to come from normally installed functionality. I'm curious about Qlemo's comment ID 35002273 that suggested sending "...a BringToFront message to that window."
0
 
ProTek2Author Commented:
The /TOP option of cmdow recommended by Olemo would be perfect if it wouldn't be labeled a virus by some of the major AV vendors. Anybody have a OS function that works?
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
Yes, that is a pity regarding AV. Be aware that cmdow is not classified as virus, but as Security Privacy Risk, because it can be used to hide windows from view. A SPR might be suspicious, but is not harmful in general. Nevertheless, some AV software will need to have an exception defined to let cmdow run ...

I did not try, but assume that the command window needs to be started from VBS to be able to bring it to front with AppActivate.

Maybe you could do better by using VBS only, which gives you more control over applications and windows.
0
 
ProTek2Author Commented:
I wouldn't be concerned about false alarms from my AV but my clients would freak out and I'd be spending all my time on the phone. :-(

So, I'm working on a purely vbs approach. The learning curve is a bit steep but I'll soon be crafting a question based on that. It would, I believe, be confusing to other readers to switch this thread to seemingly off-topic issues.
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
Agreed. If we cannot come to a solution with the means provided, the proper course is to delete the question.
0
 
ProTek2Author Commented:
I'll do that now. Thanks.
0
 
Psy053Commented:
Just out of curiosity, did you use the script as I provided or as markdormer provided?

0
 
sjklein42Commented:
Do we really need to give up so easily?

I've been playing with the VB script posted earlier.  There were a couple of issues.  One is that it assumed a temp folder that most systems won't have, so of course that had to be changed.  The other is that the title of the target window was probably not right.

When I use this procedure with the "title" command to make sure the window has the name I expect, it seems to always work.  It also needs the "start" since without it the window only "blinks" for attention instead of coming to the front.

Change the title in both places if you change it!

title ThisIsMyWindow
echo set WSHShell = WScript.CreateObject("WScript.Shell") > "C:\temp\AppAct.VBS"
echo WSHShell.Appactivate "ThisIsMyWindow" >> "C:\temp\AppAct.VBS"
start CScript "C:\temp\AppAct.VBS"

Open in new window

0
 
Psy053Commented:
Argh, I forgot to put "start" in front. Good pickup!
0
 
sjklein42Commented:
Yes, the "start" was a bit of luck and inspiration.  I saw that your script worked fine when bringing other windows to the top, but when it tried to bring itself to the top it just blinked for attention.  So I figured there was some special case for when the request comes from the same process as the window.  Then I thought of using "start" to execute the VB script in another process context, and voila!

Great teamwork.

I hope this really works.  Very useful if it does.
0
 
Psy053Commented:
Just for interests sake: "start" is also really usefull when calling scripts from Task Scheduler in Server 2008 (and probably W7), especially with scripts that use WSHShell.Run, and .AppActivate


0
 
ProTek2Author Commented:
You nailed it siklein42. Both "title" and "start" are necessary for the active window to pop itself back to the front. I actually use it more than once during the install and a subsequent "start" of the previously created "activate" file works perfectly every time.

I don't have enough points available to express my full appreciation but will split them because Psy053 got it started and hung in there.

In a few minutes I'll post a seemly unrelated question about refining the setup of a new user via vbs but it's all part of this same project.

Thanks
0
 
ProTek2Author Commented:
Thanks again
0
 
sjklein42Commented:
Thanks.  Very glad it worked!  A great example of EE teamwork.
0
 
ProTek2Author Commented:
My relentless quest to improve prompted me to ask what is essentially a follow-up question this morning:
(ID: 26855176)
0
 
ProTek2Author Commented:
That is indeed good to know... definitely filed under "good stuff" :-)

Thank you VM
0
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.

All Courses

From novice to tech pro — start learning today.