jscript

JScript: how to run external command and get output?

China☆狼群 提交于 2019-12-05 09:59:06
I'm running my JScript file using cscript.exe. In the script I need to call an external console command and get the output. Tried: var oShell = WScript.CreateObject("WScript.Shell"); var oExec = oShell.Exec('cmd /c dir'); WScript.Echo("Status "+oExec.Status); WScript.Echo("ProcessID "+oExec.ProcessID); WScript.Echo("ExitCode "+oExec.ExitCode); and var oShell = WScript.CreateObject("WScript.Shell"); var ret = oShell.Run('cmd /c dir', 1 /* SW_SHOWNORMAL */, true /* bWaitOnReturn */); WScript.Echo("ret " + ret); but no luck: the command runs (most likely) without errors but I have no output.

Prompt dialog in WSH using JScript?

青春壹個敷衍的年華 提交于 2019-12-05 01:36:40
How to open a prompt dialog box in WSH usig JScript?? The only pop-up dialog I've found in the doc is the WshShell.Popup() method. But I need a way to request the user to enter a string, like the window.prompt() method in DOM. Thanks. I think the WScript object does not provide such a method however you can show an input box from vbscript running on WSH. So here is one possible solution which lets you call that VB function from within JS! Please note the file extension for the following code fragment ".wsf". <!-- Test.wsf --> <job id="InputBoxInJS"> <script language="VBScript"> Function

Get command line arguments with jscript.net

纵饮孤独 提交于 2019-12-04 20:24:08
None of these work: var arguments = System.Environment.GetCommandLineArgs(); ~ var arguments = Environment.GetCommandLineArgs(); ~ var arguments:String[] = System.Environment.GetCommandLineArgs(); ~ var arguments:String[] = Environment.GetCommandLineArgs(); it prints JS1135: Variable 'System' has not been declared or error JS1135: Variable 'Environment' has not been declared . Even in MSDN there's no example with jscript. Is is possible to get the arguments in jscript.net ? This works: import System; var arguments:String[] = Environment.GetCommandLineArgs(); print(arguments[0]); print

How do I use jQuery in Windows Script Host?

耗尽温柔 提交于 2019-12-04 18:33:51
问题 I'm working on some code that needs to parse numerous files that contain fragments of HTML. It seems that jQuery would be very useful for this, but when I try to load jQuery into something like WScript or CScript, it throws an error because of jQuery's many references to the window object. What practical way is there to use jQuery in code that runs without a browser? Update: In response to the comments, I have successfully written JavaScript code to read the contents of files using new

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

不问归期 提交于 2019-12-03 23:49:04
问题 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? 回答1: 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,

JScript Enumerator and list of properties

丶灬走出姿态 提交于 2019-12-03 13:31:44
问题 Consider the following WSH snippet: var query = GetObject("winmgmts:").ExecQuery("SELECT Name FROM Win32_Printer", "WQL", 0); var e = new Enumerator(query); for ( ; !e.atEnd(); e.moveNext ()) { var p = e.item(); WScript.Echo(p.Name + " (" + p.Status + ")"); } It prints in every line a printer name and the word "undefined" in brackets (because Status property isn't exist in p object). The question is: how can I list all available properties from p ? The usual technique with for (var i in p) {.

How do I use jQuery in Windows Script Host?

穿精又带淫゛_ 提交于 2019-12-03 12:03:49
I'm working on some code that needs to parse numerous files that contain fragments of HTML. It seems that jQuery would be very useful for this, but when I try to load jQuery into something like WScript or CScript, it throws an error because of jQuery's many references to the window object. What practical way is there to use jQuery in code that runs without a browser? Update: In response to the comments, I have successfully written JavaScript code to read the contents of files using new ActiveXObject('Scripting.FileSystemObject'); . I know that ActiveX is evil, but this is just an internal

list of exceptions [closed]

…衆ロ難τιáo~ 提交于 2019-12-03 11:10:57
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I am looking for a list of possible exceptions in c#, c++, vb.net, j# and jscript. The problem is that some sites show me a list of 20 exceptions whereas some other site shows me a list of 39 exceptions. Can

VBS Script getElementbyID Error (AutoLogin Script)

妖精的绣舞 提交于 2019-12-02 16:59:09
问题 I am writing .vbs script file which works for different sites, but I am writing auto login script for my university web page for internet page login. So I have working til where it fills out username and password but I can't get it to click login. Here is link to university login. I am not sure that you can access it from out of network. (Note editors plz dont make it live link) hxxps://wlc-airrowdy1.utsa.edu/fs/customwebauth/studentlogin.html Here is my script code. WScript.Quit Main

VBS Script getElementbyID Error (AutoLogin Script)

爱⌒轻易说出口 提交于 2019-12-02 09:25:11
I am writing .vbs script file which works for different sites, but I am writing auto login script for my university web page for internet page login. So I have working til where it fills out username and password but I can't get it to click login. Here is link to university login. I am not sure that you can access it from out of network. (Note editors plz dont make it live link) hxxps://wlc-airrowdy1.utsa.edu/fs/customwebauth/studentlogin.html Here is my script code. WScript.Quit Main Function Main Set IE = WScript.CreateObject("InternetExplorer.Application", "IE_") IE.Visible = True IE