![]() ![]() Set exe = wso.Exec("cmd /c dir /s /b d:\temp\*.jpg") As it turns out this is easily done by set wso = CreateObject("Wscript.Shell") ![]() b somefolder\*.jpgĪnd capture the resulting output. It would be far easier to just be able to do dir /s. While not that complex it is still not trivial. To do that using the Scripting.FileSystemObject you would have to write a recursive routine that would enumerate all of the files in the given folder of that type, then call itself for each subfolder in the given folder. Let's say you want to generate a list of all of the files of a particular type in a given folder, and all subfolders. As such, you can take advantage, for example, of the increased flexibility of all of the built in commands available in a command shell. This method gives you access to the standard input, output, and error streams. However, if you want something a little more complex there is the Exec method of the same object. When you want to execute an external program for a particular result (such as resizing an image, as shown in a previous snippet) you can simply use the Run method of the Wscript.Shell object. Please see my post vbScript - The Basics for more details on vbScript. In this case, both programs use the same WSH method under the same conditions, so I don't understand why VBS correctly generate the file with 256 characters, but JScript issue an error and just generate the first 128 characters.VbScript - Run an External Program and Capture the Output However, if a try to redirect the output to a disk file, the result is very different: C:>cscript /nologo VBScript.vbs > VBScript.txtĬ:>cscript /nologo JScript.js > JScript.txtĬ:\JScript.js(2, 4) Microsoft JScript runtime error: Invalid procedure call or argument Previous output may be explained because some operative difference in JScript's fromCharCode method vs. JScript.js: for ( var i=0 i cscript /nologo VBScript.vbs ![]() ![]() I have two small programs in VBS and JScript: ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |