views:

89

answers:

6

I need an "alert" type feature to troubleshoot an error. I am not using a browser and using javascript as windows administaration purposes. So is their a way to view a varibales value if I am not using a browser?

A: 

No with javascript. You can, using Visual Basic Script and MsgBox function. No need to install anything.

'In Hello.vbs. Comments starts with '
MsgBox "Hello there"
A: 

You can create a simple file that will alert text that is passed to it, for example in python. I don't think there is any way to do this in Javascript though without a browser.

Shane Reustle
+1  A: 

On windows, you can use Windows Script Host to execute your javascript. It has a built in ability to do output, using Echo. There are some nuances though, since WSH uses jscript, not javascript, though the languages are similar.

Alan
A: 

Look at HTA files. These file types allow you to run typical HTML/VBScript/JS code without the need for a browser specifically. Just rename your HTML file to an HTA extension and run it. IT will show your "page" and execute any JS necessary. This type of file will give you access to other WScript functions as well like creating Files or accessing AD if required.

Jeff
+3  A: 

JScript is a scripting language based on the ECMAScript standard.

JScript is implemented as a Windows Script engine. This means that it can be plugged in to any application that supports the Windows Script host, such as Internet Explorer, Active Server Pages, etc. It also means that any application supporting Windows Script can use multiple languages — JScript, VBScript, Perl, and others.

For reasons that I am not sure about, but I believe it to be related to the fact the the DOM is not available outside the browser, the alert function is also not available outside the browser. In order to popup a dialog box to the user in this case you can use the following code:

WScript.Echo('The quick brown fox jumped over the lazy dog');
Bruno DeGoia
+1  A: 

If you want a windows GUI popup, then:

var timeout = 0;
var buttons = 0;  // OK
var icon = 48; // Exclamation

var shell = new ActiveXObject("WScript.Shell");
shell.Popup("text ...", timeout, "window title", buttons + icon);

and run your jscript program with the wscript command.

glenn jackman