Tag Archives: bat

bat messagebox / jscript embedded in bat

@if (@x)==(@y) @end /***** jscript comment ******
	@echo off

	cscript //E:JScript //nologo "%~f0" "%~nx0" %*
	exit /b 0
@if (@x)==(@y) @end ******  end comment *********/

/*
Value	Button
0	OK
1	OK, Cancel
2	Abort, Ignore, Retry
3	Yes, No, Cancel
4	Yes, No
5	Retry, Cancel

Value	Icon
0	No Icon
16	Critical
32	Question
48	Exclamation
64	Information
*/

var icon = 64;
var button = 0;
var title = "Sample Title";
var message = "Sample Message";
var timeout = 30;

var pressed_message = "button pressed";
var timeout_message = "timedout";


function runPopup(){
	var wshShell = WScript.CreateObject("WScript.Shell");
	var btn = wshShell.Popup(message, timeout, title, button + icon + 0x10000);

/*
Value	Return Code
1	OK
2	Cancel
3	Abort
4	Retry
5	Ignore
6	Yes
7	No
-1	None, message box was dismissed automatically (timeout)
*/
	switch(btn) {
		// button pressed.
		case 1:
			WScript.Echo(pressed_message);
			break;

		// Timed out.
		case -1:
		   WScript.Echo(timeout_message);
		   break;
	}
}

runPopup();