Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript version used by the Windows Scripting Host

I have been using JavaScript in Windows Scripting, both in .JS files and .WSF files, for several years, but I have found that there are some methods that are not recognized when I put them in a script that is executed outside a web page that are valid in a script on a web page. I know that different browsers support different versions of JavaScript, and MSDN has a page that describes which functions and methods are supported in which Internet Explorer and Edge browser versions:

https://docs.microsoft.com/en-us/scripting/javascript/reference/javascript-version-information

but it does not say which methods are supported in Windows Scripting.

Does the version of JavaScript supported in Windows Scripting depend on the version of Windows, the version of Internet Explorer installed on the computer, or some other factor or combination of factors? Is there a way inside the JavaScript program to detect which version of JavaScript is being used as it is executed?

like image 688
JDMorganArkansas Avatar asked Oct 12 '17 17:10

JDMorganArkansas


People also ask

What file types are used by the Microsoft Windows script host?

Windows script files usually have one of the following file name extensions: . wsf, . vbs, . js.

What scripting language does Windows use?

By default, the primary scripting language is VBScript. You can use any scripting language for which you have a script engine as the primary scripting language. You can set the primary scripting language on a page-by-page basis, or for all pages in an ASP application.

What is Windows Script Host?

Microsoft® Windows® Script Host (WSH) is a language-independent scripting host for Windows Script compatible scripting engines. It brings simple, powerful, and flexible scripting to the Windows 32-bit platform, allowing you to run scripts from both the Windows desktop and the command prompt.

Is JScript the same as JavaScript?

JScript: JScript is same of JavaScript as JScript was the variant of Microsoft's JavaScript. JScript was named so for it implementation because Microsoft wanted to avoid trademark issues as trademark of JavaScript is Oracle Corporation.


1 Answers

Its a common mistake to make but the Windows Scripting Host supports VBScript and Microsofts own JavaScript implementation called JScript based on the ECMAScript standard. In fact, it can support a number of scripting implementations through its support for Active Scripting languages.

While it shares many similarities with JavaScript, they are not the same (yes, they came from the same place, but that doesn't mean they didn't diverge afterwards). When you use .js files outside of the internet browser (the only browser to support Active Scripting was early versions of Internet Explorer, pre Edge) they are executed using a host program, in this case the Windows Scripting Host. This also applies when using .wsf files.

Edit: I've also updated the wsh tag info as it states javascript can be used, which is incorrect and why so much confusion arises around this topic.


Useful Links

  • Answer to What will be the status of the term JScript in MSDN?
  • JScript Language reference (via archive.org before Microsoft nuked it)
  • Answer by @dai (who was an engineer on the Microsoft JavaScript Team) regarding JScript versions
like image 95
user692942 Avatar answered Oct 03 '22 17:10

user692942