NumGuess JScript and VBScript

Two more NumGuess versions have been added bumping the total up to 39. This time it’s JScript and VBScript versions with complete Windows Script Host support. They can be run with cscript.exe for console, or wscript.exe for annoying pop up windows.

The VBScript version is almost the same as the VB.NET one, with small modifications of error handling and console input.

The JScript version was a bit more tricky. On the up side, it includes and uses the JavaScript library, which is JScript compatible. On the down side, Microsoft somehow forgot to add input box support for wscript, so it has to be invoked from a VBScript part. This is why the file extension had to be changed to .wsf and the code itself is embedded into XML.

For the record, there were two more work-arounds proposed on the internet for the above issue, none of them worked:

  • The first one involved creating a ScriptControl ActiveX object to run VBScript code directly from JScript via eval. It looked like a fairly clean solution, but it doesn’t work in 64 bit mode, and on my machine it didn’t work in forced 32 bit mode either.
  • The second proposal was to create a hidden Internet Explorer instance, load an empty page and directly call window.prompt(). Unfortunately due to IE security improvements, it crashed with access denied, and I just ended up with an unkillable hidden IE process.

So yes, the JScript version is not ideal, but it works. If wscript support is not needed, the JScript part works fine in a .js file as well.

And as always, we’re always open to new contributions.

Share Button
Tagged with:

Leave a Reply