Prev: I need a logoff script (with conditions and cancellation dialog box)
Next: Good editor for VBScript?
From: IdleBrain on 3 May 2010 09:41 Hello, As part of a VBScript, when I am trying to run the following line of code after using tempFolderLocation with Run(command), I get 'access denied' error. FSO.DeleteFolder tempFolderLocation, True However the above line removes all individual files within that folder. Using process explorer from SysInternals, I found that the Vbscript still has a file handle to tempFolderLocation. If I close the file handle to tempFolderLocation manually just before FSO.DeleteFolder executes, FSO.DeleteFolder runs fine without any error. I am interested in finding out how I can close the handle to tempFolderLocation before executing FSO.DeleteFolder. Thanks in advance.
From: Pegasus [MVP] on 3 May 2010 11:57 "IdleBrain" <indianmostwanted(a)yahoo.com> wrote in message news:d57a1921-3b2e-4347-918d-806ec0faa4b3(a)x5g2000vbf.googlegroups.com... > Hello, > As part of a VBScript, when I am trying to run the following line of > code after using tempFolderLocation with Run(command), I get 'access > denied' error. > FSO.DeleteFolder tempFolderLocation, True > However the above line removes all individual files within that > folder. > > Using process explorer from SysInternals, I found that the Vbscript > still has a file handle to tempFolderLocation. If I close the file > handle to tempFolderLocation manually just before FSO.DeleteFolder > executes, FSO.DeleteFolder runs fine without any error. > > I am interested in finding out how I can close the handle to > tempFolderLocation before executing FSO.DeleteFolder. > > Thanks in advance. Does the problem occur when you run this 2-line fragment of your code? set fso=createobject("Scripting.FileSystemObject") FSO.DeleteFolder tempFolderLocation, True If it does not then the problem is caused by whatever code you excecute before this fragment. You need to post it in order to get a good answer.
From: IdleBrain on 3 May 2010 13:17 Yes, the problem occurs when I run: FSO.DeleteFolder tempFolderLocation,True I am not running any particular code from within the 'tempFolderLocation' but I am running a batch file (.cmd) within that folder using run(command) and waiting until the batch file is completed. Even a sleep of 30s does not help with not getting 'access denied' error message.
From: Pegasus [MVP] on 3 May 2010 13:54 "IdleBrain" <indianmostwanted(a)yahoo.com> wrote in message news:f32c3b35-234d-42d0-9545-a40512b2a457(a)c11g2000vbe.googlegroups.com... > Yes, the problem occurs when I run: FSO.DeleteFolder > tempFolderLocation,True > > I am not running any particular code from within the > 'tempFolderLocation' but I am running a batch file (.cmd) within that > folder using run(command) and waiting until the batch file is > completed. > > Even a sleep of 30s does not help with not getting 'access denied' > error message. Your answer is a little ambiguous and we need to be very precise here. The questions is: Does the problem occur when you run this 2-line fragment of your code? set fso=createobject("Scripting.FileSystemObject") FSO.DeleteFolder tempFolderLocation, True In other words, does it occur when you paste these two lines into a .vbs file, replace tempFolderLocation with an actual string, then invoke the script?
From: IdleBrain on 3 May 2010 14:52 Sorry for misunderstanding your question.. I can manually go and delete the folder without any error messages or can run a script with just those two lines of code and have no problem.
|
Next
|
Last
Pages: 1 2 Prev: I need a logoff script (with conditions and cancellation dialog box) Next: Good editor for VBScript? |