Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 13 years and 3 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Hi,
I want delete all files in a folder, but I get access denied as the file is locked.
I use an email function before i'm trying to delete the files, the send email is a built in function of the application:
fcMailer.SendMailWithAttachment Process.Company, "email", Subj, "Bo", "e:uploadtest.xls"
i tried to set it to nothing: set fcMailer = nothing and set fcMailer.SendMailWithAttachment = nothing
I'm using the below to delete the files
Hi,
I want delete all files in a folder, but I get access denied as the file is locked.
I use an email function before i'm trying to delete the files, the send email is a built in function of the application:
fcMailer.SendMailWithAttachment Process.Company, "email", Subj, "Bo", "e:uploadtest.xls"
i tried to set it to nothing: set fcMailer = nothing and set fcMailer.SendMailWithAttachment = nothing
I'm using the below to delete the files
I'd suggest using OpenFiles.exe from the ResourceKit, although it might be a part of your OS now depending on what you have. On Win7 it seems to be included.
The problem about the double )) when you call the run method. Try this way. You need to copy the openfiles into the folder of your script. If you don't want to check the return code of the executable you not need to use the brackets.
If you copy the files they are not locked for reading.
If you delete the copy you have not deleted the original file and it will still exist.
I think you/we are missing someting here.
You should not delete file that are open to a task . The problemmay occur when running script under a debugger and reqquires stopping and restarting the utility. This happens with PrimalScript all of the time. It happens often when an Office application is being automated and not properly shut down.
OpenFiles is useful only if a process has aborted but leaves a thread deadlocked or hung. You need to be careful as using this incorrectly or under the wrong circumstances can destabilize as system.
OpenFiles is only useful against remote opens unless you set teh global flag for handle tracking which slows system performance.
OpenFiles is primarily a debugging tool and not really intended to be used in scripts. This is why it is hidden in the Resource Kit.
I am noting all of this because you have not really found your cause. It looks like either we misunderstood the cause or there is something else going on.
Please be aware that thes4e references to the path tools have nothing to do with the issue discussed here. FIles cannot be removed because they are locked by a process.
The need to remove the lock in code is well documented by Microsoft.
In the past most of these 'pathtoolong" and "pathtoodeep" tools have been trojans. Use them at your own risk whilenoting that they WIL NOT solve this problem.
This topic is 13 years and 3 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.