I have compared the NT version to the XP popup.exe version.
The NT version is best for me because the XP version gives me
quotation marks in the Title, I do not seem to be able to avoid.
I like the file size of the NT version.
The NT version seems to give me a default icon in the title bar I do
not seem to be able to avoid (which I can in the XP version).
Is there a way to avoid the default icon in the NT version, and if
not, is there any way to avoid the quotation marks in the XP version?
Thanks in advance.
The subroutine can be copied into any CMD script and called as in the example.
Frank
:: BEGIN SCRIPT :::::::::::::::::::::::::::::::::::::::::::::::::::::
@Echo OFF
SetLocal ENABLEEXTENSIONS
Call :MessageBox %*
Goto :EOF
::MessageBox:::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: A VBScript GUI messagebox.
:: The message is either on the commandline or in the variable
:: 'MessageBox.Message'.
:: Other optional variables:
:: MessageBox.Title The title of the messagebox window. Must be
:: quoted (i.e. Set MessageBox.Title="Title").
:: The default is the full path of the script.
:: MessageBox.Button The value of the button set to display.
:: The default is the OK button set.
:: VALUE BUTTON SET
:: OK OK
:: OKC OK CANCEL
:: ARI ABORT RETRY IGNORE
:: YNC YES NO CANCEL
:: YN YES NO
:: RC RETRY CANCEL
:: MessageBox.Icon The value of the icon to display.
:: The default is no icon.
:: VALUE ICON
:: STOP Critical Message icon.
:: QUERY Warning Query icon.
:: WARN Warning Message icon.
:: INFO Information Message icon.
:: MessageBox.Default The default button if only ENTER is pressed.
:: The default is button 0 (first).
:: MessageBox.Modal The modality.
:: 0=Normal, or application modal.
:: 1=System modal.
::
:: After returning ERRORLEVEL contains the value of the button pressed.
:: 1=OK 2=CANCEL 3=ABORT 4=RETRY 5=IGNORE 6=YES 7=NO
::
:: EXAMPLE:
:: Call :MessageBox Message to be displayed.
:: EXAMPLE:
:: Set "MessageBox.Button=OKC"
:: Set "MessageBox.Title="Message Box""
:: Set "MessageBox.Message=The default button is the CANCEL button"
:: Set "MessageBox.Icon=INFO"
:: Set "MessageBox.Default=1"
:: Set "MessageBox.Modal=1"
:: Call :MessageBox
:MessageBox [message]
For /F "delims=\" %%u in ('WhoAmI') Do (
If /I "%%u"=="nt authority" Goto :EOF
)
SetLocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
Set "ME=%~f0"
Set "MSG=%*"
If "!MSG!" EQU "" Set "MSG=!MessageBox.message!"
Set "TITLE=!MessageBox.title!"
If "!TITLE!" EQU "" Set "TITLE="%ME:~0,1%"+Chr(&H3A)+"%ME:~2%""
If DEFINED MessageBox.Button (
Set "i=0"
For %%a in (OK OKC ARI YNC YN RC) Do (
If /I "!MessageBox.Button!" EQU "%%a" Set "MessageBox.Button=!i!"
Set /A "i+=1"
)
)
If DEFINED MessageBox.Icon (
Set "i=0"
For %%a in (0 STOP QUERY WARN INFO) Do (
If /I "!MessageBox.Icon!" EQU "%%a" Set "MessageBox.Icon=!i!"
Set /A "i+=16"
)
)
Set /A "BTN=MessageBox.button|MessageBox.icon"
Set /A "BTN|=(MessageBox.Default<<8)|(MessageBox.Modal<<12)"
Set "vbs=%MY%\mb.vbs"
Echo.WScript.Quit(MsgBox("!MSG!", !BTN!, !TITLE!))>%vbs%
CSCRIPT /NOLOGO /E:VBS %vbs%
Erase "%vbs%"
Goto :EOF
:: BEGIN SCRIPT :::::::::::::::::::::::::::::::::::::::::::::::::::::
Here is one problem:
> Set "vbs=%MY%\mb.vbs"
Change %MY% to %TEMP%.
Frank
Hi Frank,
With Set "vbs=%Temp%\mb.vbs", this cmd script is perfect.
Very nice work. Modal Choice is nice. Though dependent on the
prescence of cscript, it is the only way I now have to have a popup
that does not involve an external file.
A valuable tool to have in my cmd.exe trick bag, I like it!
Thanks. (I still love the popup.exe programs !).
Ed