MPJ
(MPJ)
1
Is there any code I can add to the below in order to always have the message box on top?
It currently is on loading in the taskbar.
I need t to stay on top and continue based on error level.
I am trying to keep the code as simple and small as possible.
@echo off
call :MsgBox "WARNING INFORMATION" "VBYesNo" "QUESTION"
if errorlevel 7 (
echo NO
) else if errorlevel 6 (
echo YES
)
PAUSE
exit
:MsgBox prompt type title
setlocal enableextensions
set "tempFile=%temp%\%~nx0.%random%%random%%random%vbs.tmp"
>"%tempFile%" echo(WScript.Quit msgBox("%~1",%~2, "%~3") & cscript //nologo //e:vbscript "%tempFile%"
set "exitCode=%errorlevel%" & del "%tempFile%" >nul 2>nul
endlocal & exit /b %exitCode%
Thanks!
3 Spice ups
So many basic questions to ask…
What is the message box doing, and what environment is this running in?
Is there not a native GUI function to keep the box on top?
Why does it need to stay on top in the first place?
MPJ
(MPJ)
3
The message box is running in Windows 11 24H2.
I don’t know of a native GUI function that will keep this on top.
It needs to stay on top as it is part of our custom build process to ensure that the builders are following the process by making them confirm the process completed successfully
1 Spice up
Ok, that helps…thinking about it, where are the builders using the tool? Is it possible to have this flash up on a second screen or are they using something like a tablet? How constrained is their ‘viewing area’ already? Like, if this goes full-screen and flashes will this cause a problem? Or just a small window/grey box with a “ok/cancel” type button set? If this is a custom-built program, I take it you’re not the programmer? Can you reach out to the dev team to see about that feature?
MPJ
(MPJ)
5
It is just a normal size message box the popups on the screen and does not close until they select yes or no and then based on their choice and email is sent out letting me know the build completed successfully or that it failed.
You are correct I am not the programmer.
We had a reduction in workforce and now this is my responsibility, so I am trying to piece this together and hopefully and some point get some training, so I have a better understanding.
I just assumed all message boxes would stay on top, and I can’t figure out why this stays on the taskbar and never shows on the screen.
1 Spice up
That makes more sense…Do you know what programming language this was created in? If it’s anything but visual basic, you’ll be learning a new language soon, I’m afraid…
MPJ
(MPJ)
7
I believe Visual Basic, and it is running inside of a batch file.
1 Spice up
Well, that’s a start! Check out some VB programming threads and see if anyone has some helpful knowledge…I haven’t touched VB in 20+years.
somedude2
(somedude2)
9
Have not touched VB in ages, but, I know MS made the GUI ignore the stay on top flag in the window manager because it caused endless problems with windows deadlocking each other back in the XP era, when 2 windows insist they should be on top, what is the window manager supposed to do?
At a lower level you can do it by attaching to the display root window, that is how screen grabbers get on top of everything on the screen, but I dunno if you can do that in vb, you need a window context at a fairly low level..(and I don’t even remember all the ugly details)
The other thing that may work is to use notifications instead of a popup, they have a higher priority on the window stack than application windows, but I am not sure you can make them interactive..
1 Spice up
somedude2
(somedude2)
10
You could be annoying and just endlessly keep grabbing the keyboard focus so they can’t type anywhere else 
1 Spice up