jscript

How to pass an argument that starts with “//” to a wsh script?

馋奶兔 提交于 2019-12-01 02:45:22
问题 If I have the following script (that just prints the first argument to the console): @if (@X)==(@Y) @end /* JScript comment @echo off cscript //E:JScript //nologo "%~f0" %* exit /b %errorlevel% @if (@X)==(@Y) @end JScript comment */ WScript.Echo(WScript.Arguments.Item(0)); And I try something like C:\>test.bat "//test" I get the following error Input Error: Unknown option "//test" specified. Despite the quotes.It is taken as an option to the the windows script host. How can pass an argument

What is the Javascript method CollectGarbage()? When and why should it be used?

╄→尐↘猪︶ㄣ 提交于 2019-12-01 02:41:55
I notice in the VS2010 javascript intellisence there is a method called CollectGarbage(). Is this an IE only method? When should it be used? What are the advantages (or disadvantages) to using it? You might want to take a look at this post by Eric Lippert . Is this an IE only method? Nope. It's part of JScript, so anything that implements JScript (including IE, of course) should support it. When should it be used? When you want to hint garbage collector to start doing its job. Arguably, it shouldn't be used at all, and instead just let things happen on their own. What are the advantages (or

JScript version availability for WSH installations

让人想犯罪 __ 提交于 2019-11-30 09:19:37
问题 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. 回答1: All JScript and Windows Script Host versions are documented in MSDN: JScript Version Information Windows Script Host Version Information 回答2: 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

How can I save an MSXML2.DomDocument with indenting? (I think it uses MXXMLWriter)

梦想与她 提交于 2019-11-29 19:29:26
问题 I have an instance of MSXML2.DomDocument. I wave to save it, with indenting. This code works, but does not indent: var dom = new ActiveXObject("MSXML2.DomDocument"); // fiddle with dom here dom.save(filename); I think I can use an MXXMLWriter object to inject indenting. How? 回答1: This oughta do it. function saveDomWithIndent(dom, filename) { var writer = new ActiveXObject("MSXML2.MXXMLWriter"), reader = new ActiveXObject("MSXML2.SAXXMLReader"), fso = new ActiveXObject("Scripting

JScript version availability for WSH installations

天涯浪子 提交于 2019-11-29 14:42:30
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. All JScript and Windows Script Host versions are documented in MSDN: JScript Version Information Windows Script Host Version Information 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

What's the difference between JavaScript, JScript & ECMAScript? [closed]

余生颓废 提交于 2019-11-28 17:50:30
OK, so I'm trying to learn JavaScript properly so that I can write good, clean client-side code, but whenever I think I'm making progress, something stops me dead in my tracks! I want to know: What is the different between JavaScript, ECMAScript and JScript? Which should I focus on learning? If these are versioned, which version should I be supporting? Are there any really good references (web / books etc) that are a must have/read? How do I ensure that what I write will be compliant with all major browsers (IE, FF, Safari, Chrome, Opera etc.) ? MOST IMPORTANTLY...Is there a reference of the

Upgrading IIS/Classic ASP Javascript/JScript Scripting Engines (to Chakra?)

青春壹個敷衍的年華 提交于 2019-11-28 13:02:58
Microsoft are quoted as saying that javascript is now a first class citizen in Visual Studio and the "Universal Windows platform" but I have yet to find a way of upgrading the decade+ old JScript engine used in IIS/Classic ASP script. So, my question is, does anyone know if there is a way to do this? Why? I'd like to use JSON.parse, for example, in a classic ASP page (that uses javascript not VBScript). Currently, I'm including a copy of Crockford's old json script which is okay but these days should be unnecessary. Why? Well, as you probably know, hosts with Chakra available don't have it

ActiveX event handlers in an HTA using Javascript

你。 提交于 2019-11-28 11:50:52
In C# I can write event handlers as follows: var wdApp = new Microsoft.Office.Interop.Word.Application(); wdApp.DocumentBeforeSave += (Document doc, ref bool saveAsUI, ref bool cancel) => { //do stuff here }; In VBA/VB6, I can use static event handling: Dim WithEvents wdApp As Word.Application Private Sub wdApp_DocumentBeforeSave(ByVal Doc As Document, SaveAsUI As Boolean, Cancel As Boolean) 'do stuff here End Sub I would prefer to use dynamic event handling. However, in Javascript, even when using static event handling with the syntax described here : var wdApp = new ActiveXObject('Word

Copy folder contents to a created .zip file: 'file not found or no read permissions'

戏子无情 提交于 2019-11-28 11:42:29
I'm trying to create a .zip file from an existing folder using JScript and it seems that my copyHere function is not copying to the .zip folder. Instead I get a popup box titled 'Compressed (zipped) Folder Error' with the message 'file not found or no read permissions' even though I have read/write privileges on the file according to the value of my file.attributes property (32). Here is the script I'm using: //Get commman line arguments var objArgs = WScript.Arguments; var zipPath = objArgs(0); var sourcePath = objArgs(1); //Create empty ZIP file and open for adding var fso = new

How can I use JScript to create a shortcut that uses “Run as Administrator”

倖福魔咒の 提交于 2019-11-28 11:25:54
I have a JScript script that runs using cscript.exe . It creates a shortcut on the desktop (and in the start menu) that runs cscript.exe with parameters to run another JScript script. It looks, in relevant part, like this: function create_shortcut_at(folder, target_script_folder) { var shell = new ActiveXObject("WScript.Shell"); var shortcut = shell.CreateShortcut(folder + "\\Run The Script.lnk"); shortcut.TargetPath = "cscript"; shortcut.Arguments = "\""+target_script_folder+"\\script.js\" /aParam /orTwo"; shortcut.IconLocation = target_script_folder+"\\icon.ico"; shortcut.Save(); } It gets