jscript

How to get the main window handle of a process using JScript?

ぃ、小莉子 提交于 2019-12-10 22:18:30
问题 Is there any method in JScript to get the handle of the main window of a process by providing the process name? The Process.MainWindowHandle property works only in JScript .NET. Is anything similar available in classic JScript? 回答1: I am not sure if this works, just try to loop window.parent until its undefined. something like - var mainWindow = window; while( mainWindow.parent ) { mainWindow = mainWindow.parent; } you also have something like window.top which always returns you the topmost

Make an HTA file run as admin (elevated)

大兔子大兔子 提交于 2019-12-10 17:32:23
问题 In wsf, vbs and js files you can easily find out if they run elevated and if not you can easily make them. The code I've written for that is this: EnsureElevatedPrivileges(); WScript.Echo("Running elevated now!"); function EnsureElevatedPrivileges() { if (!WScript.Arguments.Named.Exists("elevate")) { new ActiveXObject("Shell.Application").ShellExecute(WScript.FullName, "\"" + WScript.ScriptFullName + "\" /elevate", "", "runas", 1); WScript.Quit(); } } But this doesn't work in HTA files

Is there a “createObject” in javascript?

好久不见. 提交于 2019-12-10 14:56:44
问题 In VBScript there is a function called CreateObject, which can be run on a client through a webpage. I've used it before like this: Set icaObj = CreateObject("Citrix.ICAClient") CitrixVersion = icaObj.ClientVersion To find out which version of the application was installed on the client machine. Is there something comparable in JavaScript? 回答1: Is there something comparable in JavaScript? Not in JavaScript , but in Microsoft's JScript in limited environments, yes: var icaObj = new

Writing ECMAScript5 compliant code

北城余情 提交于 2019-12-10 11:13:09
问题 I want to build a library in JavaScript/JScript/ECMAScript...whatever you want to call it, which will target modern standards (HTML5, CSS3, ESv5) with that in mind, any browser that supports the standard! Now I know there are already plenty of useful libraries out there, i.e. jQuery and MooTools. Of course they're great and I already use those where necessary, but I should not be forced to jump on the same bandwagon as every other developer just because it's popular! So for the sake of the

Property Bag in javascript

我与影子孤独终老i 提交于 2019-12-10 10:04:32
问题 I'm investigating some code outside my scope that's written in a style I've never seen before. I'm trying to understand the inner workings of the following property bag: Setter: props.Property(name) = val; Getter: val = props.Property(name); What would you need to instantiate for the setter to function as above? EDIT: Less simplification, this code IS successfully running on a BrowserWindow within a frame (similar to a phone environment). var UI = { ready: function(oProps) { try { if (oProps)

Windows Script Host (jscript): how do i download a binary file?

有些话、适合烂在心里 提交于 2019-12-09 06:22:27
问题 i'm trying to automate a file download with Windows Script Host (JScript). i see ADODB.Stream has an Open method whose documentation makes it seem like it should be possible to open a HTTP URL and stream the response body: var url = 'http://example.com/example.tar.gz'; var path = 'example.tar.gz'; var input = WScript.CreateObject('ADODB.Stream'); input.Open(url); input.SaveToFile(path); input.Close(); But it bombs on the Open call with (null): Object or data matching the name, range, or

Error adding SCRIPTITEM_CODEONLY symbol using IE9 JS engine (Chakra)

独自空忆成欢 提交于 2019-12-08 07:06:56
问题 We've been using active scripting in our browser extension (BHO) for a while with the old JScript engine (CLSID_JScript), and we recently decided to support the new IE9 script engine (Chakra) as well. One thing we do is add symbols to the engine using AddNamedItem with the SCRIPTITEM_CODEONLY option to create our own modules (namespaces). Unfortunately, we haven't been able to get this to work with Chakra. Even the most trivial example where we add a symbol and immediately retrieve its script

Windows update downloader.Download() fail

Deadly 提交于 2019-12-08 05:44:36
问题 I come across a sample vbscript program from Microsoft site regarding Windows Update(named WUA_SearchDownloadInstall.vbs). http://msdn.microsoft.com/en-us/library/aa387102%28VS.85%29.aspx Set updateSession = CreateObject("Microsoft.Update.Session") Set updateSearcher = updateSession.CreateupdateSearcher() WScript.Echo "Searching for updates..." & vbCRLF Set searchResult = _ updateSearcher.Search("IsInstalled=0 and Type='Software'") WScript.Echo "List of applicable items on the machine:" For I

Unzip a file with batch & Jscript hybrid using common variables

余生颓废 提交于 2019-12-08 00:07:00
问题 This thread shows the batch & VBS hybrid code used to unzip a ZIP archive file. Can a similar short batch & Jscript hybrid code be written, and how batch variables will be referenced in the Jscript block? Would the similar batch & wsf hybrid structure be applicable like in the referenced thread, or a different approach? <!-- : Begin batch script @echo off set "dir=%TEMP%\Unzip" & set "file=%USERPROFILE%\Downloads\archive.zip\" cscript //nologo "%~f0?.wsf" "%dir%" "%file%" exit /b ----- Begin

Is there any reason to replace JavaScript with JScript in Internet Expolorer?

大城市里の小女人 提交于 2019-12-07 14:02:45
问题 So when JScript is different from JavaScript, how does IE interpret jQuery, and all the other JavaScript-s ? Is it better to replace the JavaScript with JScript for IE? Are there any performance diferences? 回答1: JScript and JavaScript are the same. They're just aliases for each other: (via Wikipedia) As explained by JavaScript guru Douglas Crockford in his talk entitled The JavaScript Programming Language on YUI Theater, "[Microsoft] did not want to deal with Sun about the trademark issue,