Son of the Waters
Son of the Waters

Reputation: 11

Batch Script-Powershell MessageBox | How do I set TopMost within PS command line of Batch?

I created a single file to run a set of backup commands for a proprietary software that needs to run in Windows Vista thru Windows 10.

However, I am having an issue where the PS MessageBox keeps getting hidden under the CMD and PS Windows that pop-up. I know there should be a way to set the MessageBox to TopMost within the PS -Command line I am using within the batch file.

Unfortunately, I can't seem to find a good way of doing so without creating separate PS files which is not something I can do as I need this to be a single file that can be remotely transferred to multiple systems in multiple corp. environments, used by multiple agents who may not have any IT experience. This is what I am currently using that keeps getting hidden by other open windows.

powershell -Command "& {Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.MessageBox]::Show('Message', 'Title of MessageBox', 'Button', [System.Windows.Forms.MessageBoxIcon]::Information);}"

powershell -Command "& {Add-Type -AssemblyName Microsoft.VisualBasic; [Microsoft.VisualBasic.Interaction]::InputBox('Message', 'Title of InputBox')}" > %TEMP%\out.tmp

Can anyone assist with adding the TopMost=True statement to this command line?

Upvotes: 1

Views: 27

Answers (0)

Related Questions