filesystemobject

Is using the windows scripting runtime, especially the FileSystemObject thereof a good idea?

寵の児 提交于 2019-12-06 01:16:05
Recently I have been asked to do some maintenance on a VB6 application. This involves some file IO. I find the IO operations offered by referencing the windows script host and using the FileSystemObject a lot friendlier than the IO operations that come with VB6. But will this cause problems because of security issues, or because of the fact that the script host will be disabled on some users' computers? Update (aug 20, 2012): Since asking this question we have encountered the problem of a non functional scrrun.dll three times among 3000 customers. We had to fix these manually through remote

Using “FSO” in Javascript, how to write a variables's content to a file? [duplicate]

牧云@^-^@ 提交于 2019-12-02 13:34:06
Possible Duplicate: how to write a variables's content to a file in JavaScript I have this piece of code to create a text file. How can I write to this text file? function makefile() { var fso; var thefile; fso = new ActiveXObject("Scripting.FileSystemObject"); thefile=fso.CreateTextFile("C:\\tmp\\MyFile.txt",true); thefile.close() } Here's one way: makefile(); function makefile () { var fso = new ActiveXObject("Scripting.FileSystemObject"), thefile=fso.CreateTextFile("C:\\temp\\MyFile.txt",true); thefile.WriteLine('abc'); thefile.Close(); } Bear in mind this will only work in IE with the

Using VBA FileSystemObject, specific file File extension

流过昼夜 提交于 2019-12-02 03:34:29
问题 I'm using the following code to list all files with xls,xlsx or xlsm extension from folder and its subfolder. The following code works but the problem is, it lists all files with all extensions from subfolders but lists only excel files from main folder. I can not figure out whats wrong with this code. Could you please help me? Sub List_XL_Files(ByVal SheetName As String, ByVal SourceFolderName As String, ByVal IncludeSubfolders As Boolean) Dim FSO As Object Dim SourceFolder As Object Dim

Using VBA FileSystemObject, specific file File extension

百般思念 提交于 2019-12-02 01:24:22
I'm using the following code to list all files with xls,xlsx or xlsm extension from folder and its subfolder. The following code works but the problem is, it lists all files with all extensions from subfolders but lists only excel files from main folder. I can not figure out whats wrong with this code. Could you please help me? Sub List_XL_Files(ByVal SheetName As String, ByVal SourceFolderName As String, ByVal IncludeSubfolders As Boolean) Dim FSO As Object Dim SourceFolder As Object Dim SubFolder As Object Dim FileItem As Object Dim lRoMa As Long Set FSO = CreateObject("Scripting

Excel VBA efficient get file names function

送分小仙女□ 提交于 2019-12-01 03:56:58
I need to get a collection of file names from a folder on a remote server using VBA in excel 2010. I have a function that works and in the majority of cases it would do the job, however the remote server frequently has terrible, terrible network performance issues. This means that looping through say 300 files to put their names into a collection can take 10 minutes, the number of files in the folder is likely to grow to thousands so this is not workable, I need a way to get all of the file names in a single network request and not looping. I believe its connecting to the remote server that is

How to use FileSystemObject to read file in JavaScript

早过忘川 提交于 2019-11-30 21:04:02
I want to read a file with FileSystemObject. My code is as following: <!DOCTYPE html> <html lang="en"> <head> <title>Read json</title> </head> <body> <script type="text/javascript"> function readFile(filename){ var fso = new ActiveXObject("Scripting.FileSystemObject"); var ForReading = 1; var f1 = fso.OpenTextFile(filename, ForReading); var text = f1.ReadAll(); f1.close(); return text; } myJSONText = "text.txt"; var myObject = readFile(myJSONText);//eval('(' + myJSONText + ')'); document.write(myObject.name); </script> </body> </html> Aaron Thomas First, let me repeat some comments above. I've

If file exists then delete the file

我们两清 提交于 2019-11-30 20:59:08
I have a vbscript that is used to rename files. What I need to implement into the script is something that deletes the "new file" if it already exists. For example: I have a batch of files that are named like this 11111111.dddddddd.pdf where the files get renamed to 11111111.pdf. The problem is that when I rename to the 11111111.pdf format I end of with files that are duplicated and then makes the script fail because you obviously cant have 2 files with the same name. I need it to rename the first one but then delete the others that are renamed the same. Here is what I have so far for my IF

How can I determine if a file is locked using VBS?

久未见 提交于 2019-11-30 09:18:47
问题 I am writing a VB Script to update some files on the network. Before beginning, I want to know if any of the files are locked. I'd like to do this before I actually do any updates. I am aware that I can handle the error if the file is locked when I try to replace it, but I really want to know if any files are locked before I start updating any files. Is there any way to see that a file is locked using VBS (apart from trying to replace it)? 回答1: This function determines whether a file of

How can I determine if a file is locked using VBS?

与世无争的帅哥 提交于 2019-11-29 14:36:19
I am writing a VB Script to update some files on the network. Before beginning, I want to know if any of the files are locked. I'd like to do this before I actually do any updates. I am aware that I can handle the error if the file is locked when I try to replace it, but I really want to know if any files are locked before I start updating any files. Is there any way to see that a file is locked using VBS (apart from trying to replace it)? This function determines whether a file of interest can be accessed in 'write' mode. This is not exactly the same as determining whether a file is locked by

Access files with long paths (over 260)

眉间皱痕 提交于 2019-11-29 07:06:37
I'm using Microsoft Scripting Runtime (FSO) to parse folders and produce a list of all of its contents, the folders are on a network and resultant paths end up longer than 260. The minimum code I have is as below:- Private Sub ProcessFolder(ByVal StrFolder As String) Dim Fl As File Dim Fldr As Folder Dim RootFldr As Folder Set RootFldr = FS.GetFolder(StrFolder) For Each Fl In RootFldr.Files Debug.Print Fl.Path Next For Each Fldr In RootFldr.SubFolders DoEvents ProcessFolder Fldr.Path Next Set RootFldr = nothing End sub At a certain level StrFolder length became 259, the Set RootFldr ... folder