I am writing a batch script to open a series of MessageBox and InputBox windows. The program works well when it is first launched and the users are able to interact with the windows, but if they click on any other programs it brings them to the foreground and essentially hides the message/input boxes. Here is an example of two of the boxes, how can I keep these always on top of other windows while the program is being used?
powershell -Command "& {Add-Type -AssemblyName Microsoft.VisualBasic; [Microsoft.VisualBasic.Interaction]::InputBox(\"`r`nEnter the unique component number:`r`n\", 'Component Number')}" > %TEMP%\uniqueno1.tmp
set /p UniqueNo1=<%TEMP%\uniqueno1.tmp
powershell [Reflection.Assembly]::LoadWithPartialName("""System.Windows.Forms""");[Windows.Forms.MessageBox]::show(\"Unique Component Number %UniqueNo1%`r`n`r`n Click OK on this window to continue\", 'Component Number',0)>nul
Try this:
Flag enum 131072 stands for DefaultDesktopOnly.
See https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.messageboxoptions?view=windowsdesktop-7.0
Alternative could be
(new-object System.Windows.Window -Property @{TopMost = true})But this one didn't work for me. Maybe it's meant to be used in a other way, no idea.