• Announcements

    • xper

      MSFN Sponsorship and AdBlockers!   07/10/2016

      Dear members, MSFN is made available via subscriptions, donations and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, become a site sponsor and ads will be disabled automatically and by subscribing you get other sponsor benefits.
phan

Tiny command line utility msgbox.exe with timeout option

18 posts in this topic

I searched for such tool but did not find so I wrote myself. Maybe some of you can make use of this tiny tool

Features:

- standard styles (yes/no, ok/cancel, abort/retry,...) and icons

- selectable default button with timeout option

- only 1KB

Download: msgbox.cab

0

Share this post


Link to post
Share on other sites

Dude this is sweet... might be awesome for my INF uninstallers

0

Share this post


Link to post
Share on other sites

OK I got the message boxes but n00b question:

How do i use the choices? meaning when i select OK or Cancell how do I use the number to go to a choice?

0

Share this post


Link to post
Share on other sites

use errorlevel, for example:

 msgbox "Setup will continue in %%d seconds." "Setup" 65 15
if errorlevel 2 goto :cancel

rem *** put your stuff here in case the user clicks on OK or timed out ***

:cancel

Here are the errorlevels returned:

0 Timed out

1 OK

2 Cancel

3 Abort

4 Retry

5 Ignore

6 Yes

7 No

You can also use %ERRORLEVEL% as environment variable, i.e.

if "%ERRORLEVEL%"=="5" goto :ignore

if "%ERRORLEVEL%"=="4" goto :retry

if "%ERRORLEVEL%"=="3" goto :abort

Edited by phan
0

Share this post


Link to post
Share on other sites

:yes: wonderful my friend. thank u very much. ive been looking for this kind of app to execute cmds based on the user interest. u have fulfilled my interest. :thumbup

Youve just got my 200th post. :whistle:

Edited by rajesh.kumar
0

Share this post


Link to post
Share on other sites

thank u all :wub:

@rajesh: I'll wait for ur 999th post :rolleyes:

btw, note on the double percent sign %%d above: this is because calling in cmd-file. If you run msgbox from other program, use only one percent sign %d (like printf())

And the number 65 in the example above is sum of 1+64 (OK Cancel + Information Icon). You may combine following box styles:

Buttons:

0 OK

1 OK Cancel

2 Abort, Retry, Ignore

3 Yes, No, Cancel

4 Yes, No

5 Retry, Cancel

Icon:

16 Error

32 Question

48 Exclamation

64 Information

Default button:

256 make 2nd button default

512 make 3rd button default

0

Share this post


Link to post
Share on other sites

is there a way to modify the caption of buttons like OK, Cancel etc

0

Share this post


Link to post
Share on other sites
Buttons:

0 OK

1 OK Cancel

2 Abort, Retry, Ignore

3 Yes, No, Cancel

4 Yes, No

5 Retry, Cancel

The first param is the messagebox text, the second is the window title, third is the sum of the buttons + icon + default, fourth is the timeout in seconds.

0

Share this post


Link to post
Share on other sites

Could you add a switch to always return errorlevel 0. I would like to use msgbox.exe as a program in MS SMS, and errorlevel <> 0 cause a stop.

thanx for an excellent program

0

Share this post


Link to post
Share on other sites

Msgbox.exe - virus alert ???

My Avira Personal Antivirus send alarm when unpacking msgbox.cab

True virus ???

0

Share this post


Link to post
Share on other sites

msgbox.cmd contains the text "format c:" - try changing that to something else and scan the extracted files again?

virustotal.com seems busy at the moment.

0

Share this post


Link to post
Share on other sites

Sintaxis

for print time add "in %%d"

If you run msgbox from other program, use only one percent sign %d (like printf())

"<Message>" "<Title>" "<Flag #1-5>" "<seconds>"

for non timeout use in seconds "0"

Flags:

You may combine following box styles:

0 = OK

1 = OK + Cancel

2 = Abort + Retry + Igonore

3 = Yes + No + Cancel

4 = Yes + No

5 = Retry + Cancel

6 = Cancel + Retry + Continue

Icon:

16 Error

32 Question

48 Exclamation

64 Information

Here are the errorlevels returned:

0 Timed out

1 OK

2 Cancel

3 Abort

4 Retry

5 Ignore

6 Yes

7 No

11 Continue

You can also use %ERRORLEVEL% as environment variable, i.e.

if "%ERRORLEVEL%"=="5" goto :ignore

if "%ERRORLEVEL%"=="4" goto :retry

if "%ERRORLEVEL%"=="3" goto :abort

0

Share this post


Link to post
Share on other sites

Anyone got something like this that works on Win7 x64?

0

Share this post


Link to post
Share on other sites

Anyone got something like this that works on Win7 x64?

Here's a simple one line command that can be used inside a batch file. No problems with Win7 x64.

echo msgbox"my important message",64,"Some Import Title"> a.vbs & cscript a.vbs //T:5 & del a.vbs

Set your timeout by changing the //T:5 value

Coding References:

MsgBox: http://www.w3schools.com/vbscript/func_msgbox.asp

CScript: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/cscript_overview.mspx?mfr=true

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.