Call an .EXE and make it stay on top?

Started by jkjk12, October 13, 2014, 09:18:43 AM

Previous topic - Next topic

jkjk12

Is there a way to call an external .EXE and force it to stay on top of other windows?   I have an .EXE (not written in WinBatch) and when it runs it throws up a menu for users to see.   I need this menu to always stay on top of other windows.  Can WinBatch solve that? 

snowsnowsnow

IntControl(54).

Or WindowOnTop() (I think, I've never used that)

Anyway, you just give it a partial window name and it will make that window name stay on top.

jkjk12

I tried both the IntControl and WindowOnTop and neither works.   the called program remains behind other application windows.   Here is my whole script.

Run("\\ServerName\Scripts\Tools\MGHRebootTool\RebootUtility.exe","")
WindowOnTop("MGH",1)

The full window title is MGH too.    The RebootUtility.exe does launch but I never see it since I have other apps open.   How do I make it "Front and Center" on top of any/all other windows?

....IFICantBYTE

What snow suggested and what you did should have worked.
You also would have had an error pop up if the Window name was wrong and couldn't be found, so I'm guessing that it "worked", it's just that your "MGH" window must ignore the request to change its z layer (ordering) state or it updates/resets it every so often itself?

Try the same code with a different window and it will more than likely work.. it might just be this one that wont play the game.

Perhaps the RebootUtility.exe (the MGH window) has some option, start-up parameter or registry setting that controls its own visibility level?
OR even more radical ... perhaps you can get rid of that utility and write your own equivalent one in Winbatch? ... Winbatch has some reboot commands.... then you can control everything.

Good luck. 
Regards,
....IFICantBYTE

Nothing sucks more than that moment during an argument when you realize you're wrong. :)

jkjk12

Hi.  I am 1 week into coding a reboot utility for our company so I can't change programming tools midstream.  Plus we are trying to use only PowerShell for all scripting needs.  I know how cool WinBatch so I talked my manager into buying it since it does stuff PS can't do (like answer an "ok" button in memory using RoboScript").    Now, back to our issue at hand.....

when I run my script it does put the MGH window on top.......but if start up another app before it launches then it does not.  Example:


Run("\\ServerName\Scripts\Tools\MGHRebootTool\RebootUtility.exe","")
TimeDelay(4)
WindowOnTop("MGH",1)

I run the above code, then switch to Outlook.   I see the TaskBar icon appear but it stays hidden behind Outlook (or any app I have open).     I'm trying to run RebootUtility.exe from GPO's and when a user logs it then .EXE does run but it takes about 5-8 seconds and that is enough time for users to launch IE or other apps.  That is how I stumbled across this issue, when I had a user test it.

I wrote this Reboot tool using Sapian PowerShell Studio so I will see if there is anything I can do with that tool.


....IFICantBYTE

Oh.. so you wrote the reboot utility and have to keep it in powershell... that changes things a bit.
Well I'm not familiar with the Sapian powershell stuff (I use WinBatch for almost everything), but if it uses Windows Forms to display GUIs (probably does) then you should have a way to make it the top-most window.

Something like Form.TopMost = true

Have a look here at general Windows forms stuff:
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.windowstate(v=vs.110).aspx

Regards,
....IFICantBYTE

Nothing sucks more than that moment during an argument when you realize you're wrong. :)

td

Recoding the utility is the best advice in this case.  When that is not an options, calling WinActivate("") to make the script the active window before calling WindowOnTop may (or may not) work around the problem.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade