Display a popup from a batch fileTag(s): Misc Prog HowTo


The goal is to display a popup, the calling batch file must stop and wait the popup closing.
Using powershell
echo calling popup
powershell [Reflection.Assembly]::LoadWithPartialName("""System.Windows.Forms""");[Windows.Forms.MessageBox]::show("""rgagnon.com""", """HowTo""",0)>nul
echo we are back!
Using MHTA
echo calling popup
mshta javascript:alert("rgagnon.com\n\nHowTo!");close();
echo we are back!
Regular CMD
echo calling popup
START /WAIT CMD /C "ECHO rgagnon.com && ECHO HowTo && ECHO. && PAUSE"
echo we are back!
Using JScript
 @if (@x)==(@y) @end /***** jscript comment ******
     @echo off
     echo calling popup
     cscript //E:JScript //nologo "%~f0" "%~nx0" %*
     echo we are back!
     exit /b 0
 @if (@x)==(@y) @end ******  end comment *********/

var wshShell = WScript.CreateObject("WScript.Shell");
wshShell.Popup("HowTo", -1, "rgagnon.com", 16);

blog comments powered by Disqus