jscript

hide Excel tab from Javascript code

爷,独闯天下 提交于 2020-01-21 09:43:39
问题 How can I hide an Excel tab programmatically through Javascript. ExcelSheetName.Visible=False doesn't seem to work. I've googled a lot but yet not received the right solution. How to do that ? 回答1: To hide an Excel sheet, set the Visible property of the corresponding Worksheet object to 0 or false . For example, if you have an Excel file with two sheets named Sheet1 and Sheet2 , the following code will open this file with the Sheet1 hidden: var objExcel = new ActiveXObject("Excel.Application"

Equivalent to window in JScript Runtime

强颜欢笑 提交于 2020-01-15 03:17:26
问题 In a normal browser javascript environment, you always have the global window object to fall back on but is there a default accessible global object for the Microsoft JScript Runtime or at least a way to check for one? 回答1: According to MSDN, there is a Global object, however a quick test reveals that it is not directly accessible: WScript.Echo(Global.escape('hello world')); // Error: 'Global' is undefined What you can do, however, is take advantage of the fact that this in a global context

Documenting the return of a javascript constructor with jsdoc

[亡魂溺海] 提交于 2020-01-14 12:52:35
问题 I have a javascript function that returns a constructor (see code sample below). How would I document this with the @returns tag of jsdoc. It doesnt seem correct to do @returns {MyConstructor} because that implies I am returning an instance of "MyConstructor" rather than the constructor itself, right? function MyConstructor() { var self = this; self.myFunction = function() { return true; }; self.getMyFunctionResult = function() { return self.myFunction(); }; } /** * @returns {?} A constructor

How can I split a binary file into chunks with certain size with batch script without external software?

≡放荡痞女 提交于 2020-01-11 06:43:30
问题 There are many reasons to want to split file into chunks - mainly for network transfer (e.g. e-mail attachments) but I'm sure there are scenarios that could require such thing I cannot imagine. So how can a file be split into chunks that can be easily assembled back to original file (including non-windows systems) ? What are possibilities: MAKECAB - the built-in Windows archiver - it can compress file and split it , but will be difficult to assemble the file on non-Windows machine. WSH

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

风流意气都作罢 提交于 2020-01-09 10:44:07
问题 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\"

Use Scripting.FileSystemObject to create file in path that doesn't already exist

此生再无相见时 提交于 2020-01-05 09:03:13
问题 I'm trying to create a text file using the Scripting.FileSystemObject in JScript. I can't seem to figure out how to create the file if a directory in the file doesn't already exist. For example: var fso = new ActiveXObject("Scripting.FileSystemObject"); // Getting a JScript runtime error of "Path not found" fso.CreateTextFile("\\\\pathA\\pathB\\DirectoryDoesntExistButIWantItTo\\newfile.txt", true); I've been looking all over but it seems like the documentation on this isn't neatly put in one

Invoking functions with `out` arguments, passing arguments by reference in JScript

一笑奈何 提交于 2020-01-04 09:07:31
问题 I'm using following code in JScript (WSH) to connect to local registry using WMI: var registry = GetObject('winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\default:StdRegProv'); and that works. Then I have to determine if I'm allowed to delete key without really trying to delete it (e.g. perform a non-destructive check). I looked over docs and found that I need StdRegProv.CheckAccess() method. Problem is that CheckAccess returns result as out argument and I could not find VBScript's

Ping error return always equals 0

梦想与她 提交于 2020-01-04 05:18:05
问题 Having trouble getting this code to work. I can run the script (with changes) in vbscript and it runs fine. But I cant get this version to return a ping error return value other than 0. Any help is appreciated. This is scanning a list of remote machines with checkboxes and returning the checked values. I want to run the ping to verify the remote machine are there before continuing. But with a error return of 0 for all queries its useless. function statuschk3(){ var checkedValue = null; var

JScript: how to run external command and get output?

痞子三分冷 提交于 2020-01-02 04:06:05
问题 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

ADODB Command failing Execute with parameterised SQL query

﹥>﹥吖頭↗ 提交于 2019-12-31 03:36:09
问题 I have the following JScript code: var conn = new ActiveXObject ("ADODB.Connection"); conn.Open("Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=blah_blah_blah;User=foo;Password=bar;"); var cmd = new ActiveXObject("ADODB.Command"); cmd.ActiveConnection = conn; var strSQL = "SELECT id FROM tbl_info WHERE title LIKE :search ORDER BY id"; var search = "test"; try{ cmd.CommandText = strSQL; var param = cmd.CreateParameter(':search', 200, 1, 100, search); cmd.Parameters.Append(param); var