filesystemobject

If file exists then delete the file

有些话、适合烂在心里 提交于 2019-12-30 06:43:28
问题 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

fs.DeleteFile(var) not deleting file

夙愿已清 提交于 2019-12-25 08:48:26
问题 On a few of our sites we are running a backup script that saves a MSSQL database as a .bak file in a that directory. Every day we run a Git style backup so that we have any changes to the site. Due to variance in backup timing We don't really want to delete today's backup, or yesterday's, so we will delete 3 days past. The following .asp page runs fine if the DeleteFile(line 30) is commented out. if the file exists it follows the correct branch, so it can see the file, but if the delete line

Quickest way to determine if a remote PC is online

岁酱吖の 提交于 2019-12-24 17:42:37
问题 I tend to run a lot of commands against remote PCs, but I always check to make sure they are online first. I currently use this code: If objFSO.FolderExists("\\" & strHost & "\c$") Then 'The PC is online so do your thing However, when the remote PC is not online, it takes my laptop ~45 seconds before it times out and resolves to FALSE . Is there a way to hasten the timeout? Or is there another easily implementable solution to determine if a PC is online? 回答1: You could use WMI to ping it.

Is there an alternative to Scripting.FileSystemObject in Excel 2011 VBA for the mac?

不想你离开。 提交于 2019-12-24 09:28:10
问题 The answers to How can I install/use “Scripting.FileSystemObject” in Excel 2011 for MAC? seem to indicate that using Scripting.FileSystemObject in Excel 2010 for the mac is not possible. What other alternative is available so I can: get a collection of all Excel files in a specific directory iterate through each worksheet within each file and export it to a .csv file Currently this is a six-step process for each file: --how to create CSV files for all worksheets in a file: 1. open file 2.

Can't write file in classic asp

拈花ヽ惹草 提交于 2019-12-23 20:37:17
问题 Ok, it's been a while since I've worked with classic asp so I'm a bit rusty. Here's my question. I'm trying to write a file to the file system using FSO. The code below is very simple. However, the file is not appearing and no errors are appearing. I know it's running the code because I can add response.writes before and after this snippet and they both appear in the output. However, no file is created, no error is thrown. I've even changed it so it's a bogus path to force an error. No dice.

vbscript skipline and cr line endings

冷暖自知 提交于 2019-12-23 05:06:05
问题 For some reason when I use the objFile.ReadLine method to read my text file, the entire file is returned as one long line. The file I'm opening is using CR line endings instead of CRLF or LF line endings. Does anyone know how I can read this file line by line in vbscript if ReadLine does not recognize CR line endings? Code is below: Set objFSO = CreateObject("Scripting.FileSystemObject") Set txsInput = objFSO.OpenTextFile("C:\Path\To\My\File.csv",1) 'Read lines one by one Do While txsInput

Get contents of laccdb file through VBA

会有一股神秘感。 提交于 2019-12-21 04:50:46
问题 I want to be able to view the contents of my access database's laccdb file through VBA so I can use it to alert users (through a button) who else is in the database. I specifically don't want to use a 3rd Party tool . I have tried using: Set ts = fso.OpenTextFile(strFile, ForReading) strContents = ts.ReadAll This works fine if only 1 user is in the database. But for multiple users it gets confused by the presumably non-ASCII characters and goes into this kind of thing after one entry: Does

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

[亡魂溺海] 提交于 2019-12-20 07:51:03
问题 This question already has answers here : Closed 8 years ago . 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() } 回答1: Here's one way: makefile(); function makefile () { var fso = new ActiveXObject("Scripting

How do I Replace a String in a Line of a Text File Using FileSystemObject in VBA?

微笑、不失礼 提交于 2019-12-19 07:22:29
问题 I am trying to use FileSystemObject methods to find a specific line in a text file, and within that line replace a specific string. I am relatively new to this, as my current code has excel open the text file and replace what I need it to replace then save and close it. This way is no longer an option, as having excel open the text file takes too long and holds up the file. This is how far I have gotten so far. - Sub FindLines() Const ForReading = 1 Set FSO = CreateObject("Scripting

How to use FileSystemObject to read file in JavaScript

余生颓废 提交于 2019-12-19 03:25:18
问题 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