wsh

in JavaScript, when finished with an object created via new ActiveXObject, do I need to set it to null?

雨燕双飞 提交于 2020-02-03 10:25:28
问题 In a Javascript program that runs within WSH and creates objects, let's say Scripting.FileSystemObject or any arbitrary COM object, do I need to set the variable to null when I'm finished with it? Eg, am I recommended to do this: var fso = new ActiveXObject("Scripting.FileSystemObject"); var fileStream = fso.openTextFile(filename); fso = null; // recommended? necessary? ... use fileStream here ... fileStream.Close(); fileStream = null; // recommended? necessary? Is the effect different than

.bat for batch rename to increment numbers in fname

北慕城南 提交于 2020-01-29 21:37:08
问题 I have a large folder of .cbr's, and I'm renaming them by issue number to correctly order them. What do I need to include in the ren line to have each file increment the number in the file name via windows command prompt? I'll be doing this frequently so I'll make this a .bat file. For example, where n = initial number and m = final number: n.cbr, (n+1).cbr, ..., (m-1).cbr, m.cbr The .bat thusfar: ren *.cbz *.cbr ren *.cbr <increment numbers n through m>.cbr Alternatively, how do I trim each

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"

Running Javascript with CScript?

给你一囗甜甜゛ 提交于 2020-01-21 02:39:09
问题 I'm trying to learn how to run Javascript (instead of VBScript) using CScript.exe, but when I try, I get an error: cscript temp.js Input Error: There is no script engine for file extension ".js". I thought this is possible -- any idea what's wrong? 回答1: Setting the registry with regsvr32 did not work for me. Also, I don't want it, since I want my .js to be linked with a plain text editor. But there is a command line option //E for cscript which makes the job: cscript //E:jscript hello.js 回答2:

Can't run DIR from WScript Shell in VBA?

折月煮酒 提交于 2020-01-20 08:38:10
问题 I use the following function in a lot of my VBA projects. I initially added the reference to Windows Script Host Object model to take advantage of Intellisense, but then switched to late binding so I didn't have to reference a bunch of stuff. Private Function RunCMD(ByVal strCMD As String) As String 'Runs the provided command Dim oShell As Object 'New WshShell Dim cmd As Object 'WshExec Dim x As Integer Const WshRunning = 0 On Error GoTo wshError x = 0 RunCMD = "Error" Set oShell =

Can't run DIR from WScript Shell in VBA?

孤街醉人 提交于 2020-01-20 08:38:08
问题 I use the following function in a lot of my VBA projects. I initially added the reference to Windows Script Host Object model to take advantage of Intellisense, but then switched to late binding so I didn't have to reference a bunch of stuff. Private Function RunCMD(ByVal strCMD As String) As String 'Runs the provided command Dim oShell As Object 'New WshShell Dim cmd As Object 'WshExec Dim x As Integer Const WshRunning = 0 On Error GoTo wshError x = 0 RunCMD = "Error" Set oShell =

Capturing output from WshShell.Exec using Windows Script Host

安稳与你 提交于 2020-01-19 05:50:06
问题 I wrote the following two functions, and call the second ("callAndWait") from JavaScript running inside Windows Script Host. My overall intent is to call one command line program from another. That is, I'm running the initial scripting using cscript, and then trying to run something else (Ant) from that script. function readAllFromAny(oExec) { if (!oExec.StdOut.AtEndOfStream) return oExec.StdOut.ReadLine(); if (!oExec.StdErr.AtEndOfStream) return "STDERR: " + oExec.StdErr.ReadLine(); return

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

VBS Remove Readonly attribute recursivelty

岁酱吖の 提交于 2020-01-14 06:28:27
问题 I'm very new to VBS and experimenting with removing the read only attribute from a directory recursively. It's removing the read only attribute for files but not for the directories. Also The files within these directories seem to have lost their associated program link and are now all showing as an unregistered file type. Any help is greatly appreciated. Update: I can see why the files have lost their associations now. It's because the . which separates the name from the extension has been

run vb script using script.exe

会有一股神秘感。 提交于 2020-01-14 05:14:11
问题 I want to run vbscript file using cscript.exe. i searched a lot but did'nt found any way while i can run my script using cmd with cscript.exe this is my code Process p = new Process(); p.StartInfo.Arguments = @"C:\\Program Files\\VDIWorkLoad\\WorkLoadFile\\open test.vbs"; p.StartInfo.FileName = "testing"; p.StartInfo.UseShellExecute = false; try { p.Start(); p.WaitForExit(); Console.WriteLine("Done."); } any idea how i can use cscript.exe 回答1: You should set the FileName property to the