Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
469 views
in Technique[技术] by (71.8m points)

automation - JScript version availability for WSH installations

I'm not sure if JScript for WSH is available in every windows installation.

Which version of JScript is available for WSH, and in which windows version?

Please provide the link to an authoritative source.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

One not obvious nuance: JScript works like version 5.7 in Windows Script Host 5.8.

From MSDN: Note Starting with JScript 5.8, by default, the JScript scripting engine supports the language feature set as it existed in version 5.7. This is to maintain compatibility with the earlier versions of the engine. To use the complete language feature set of version 5.8, the Windows Script interface host has to invoke IActiveScriptProperty::SetProperty. (MSDN, JScript Version Information)

Worse yet, JScript claims version 5.8 (not 5.7) in such default case (see output of [ScriptEngineMajorVersion(), ScriptEngineMinorVersion()]).

JScript 5.8 introduced the following features: JSON object, JSON.parse method, JSON.stringify method, toJSON method, defineProperty method, getOwnPropertyDescriptor method.

Unfortunately, no simple way to use these features in cscript (or wscript) host of version 5.8. Update: one trick was found by @rojo in 2015. The trick is based on htmlfile COM object and it allows to use at least some of the mentioned features.

See also question 19445189 cscript jscript JSON.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...