A simple method to help you delete an undeletable or locked file. Have you ever run into a situation where you wanted to delete a file, but Windows simply wouldn’t allow you to do it? Personally, these things happen to me all the time, especially when I’m at a. Tinfanide In DOS commands, the command TASKKILL can do the job (with reference to the task's Window Title). That is why I have been wondering if vbscript can do the same job or if not, then run a batch file from vbscript.VBScript itself does not support selecting.Use vbscript to modify a text file. Every day we get a flat text file. Some days there are lines in the file that need to be deleted before it can be processed. These lines can appear in different places, but always start with the characters 6. We would like to run a script that will delete these particular lines. However, and this is way beyond me, any where there is a line that starts 6. We are a Windows shop and would run this script as part of a simple batch file in Windows. We do not use Unix or Linux nor desire to. The file name extension reflects the date. I am having trouble with this aspect, as it seems vbscript does not like file.*Here is a sample of the text file: 4. We'd like to remove 5 lines in this file (the 5. Here is a sample of the script that I found on this site, have modified and had some success, but don't know the way to delete the lines (only know how to replace data in the line). I realize this will either need major modifications or need to be thrown out altogether, but I post this to provide an idea of what I think we are looking for. I put this in a directory with the cscript. Set obj. FS = Create. Object("Scripting. File. System. Object"). File = "c: \temp\file. Set obj. File = obj. FS. Open. Text. File(str. File). Do Until obj. File. At. End. Of. Stream. str. Line = obj. File. Read. Line. If In. Str(str. Line,"6. Then. str. Line = Replace(str. Line,"6. 99. 9","delete line"). WScript. Echo str. Line. Which gets me this: 4. Close! just need to delete lines instead of write "delete line". So here are my specific needs based on what I know: Get the script to process any file in the directory (and there will only ever be 1 at a time, but the extension changes every day) Get the script to delete any line that starts with a 5. Get the script to totally delete those lines that start with 6.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
October 2016
Categories |