| T O P I C R E V I E W |
| Carefree |
Posted - 18 January 2011 : 06:06:56 Here's an excerpt from a script:
I get occasional permission denied runtime errors (800a0046) for the first line in this routine. The folders in question all have permissions granted and there aren't any restricted system folders involved. How can I determine the objItem.Name in question when it fails? |
| 11 L A T E S T R E P L I E S (Newest First) |
| HuwR |
Posted - 20 February 2011 : 03:03:40 ok, I think the problem is that it is trying to iterate through a hidden directory rather than it being a file that is the problem, so you probably need to check the folder attributes before trying to iterate through it's files.
Maybe something like this
SET oFSO = WScript.CreateObject("Scripting.FileSystemObject")
SET oFolder = oFSO.GetFolder("C:\MyPath")
If oFolder.Attributes AND 2 then
//Folder is hidden so don't iterate the files
else If oFolder.Attributes AND 4
//System folder so don't iterate the files
else
For Each oFile In oFolder.Files
If oFile.Attributes And 2 Then
WScript.Echo oFile.Path & " is Hidden"
End If
Next
End If
|
| Carefree |
Posted - 20 February 2011 : 01:20:43 Didn't solve the issue, Huwr, but may have resulted in a slight speed improvement not using the collection. |
| HuwR |
Posted - 19 February 2011 : 08:20:11 I don't think this will matter, but worth checking.
1) you are setting objFSO twice, why? you don't need to do the second SET since you already have a valid objFSO 2) try not setting colfiles and do the iteration directly on onjFolder.Files it may make a difference, it could be that creating files object works differently in this instance. |
| Carefree |
Posted - 19 February 2011 : 07:35:00 Modified to remove sensitive info:
|
| HuwR |
Posted - 19 February 2011 : 04:44:44 are you sure it is erroring on the first line and not elsewhere, you should be able to iterate through a directory without it erroring on hidden/special files, since you should be able to display it's properties/attributes hidden or not, it should only error if you try to open them.
for example
SET oFSO = WScript.CreateObject("Scripting.FileSystemObject")
SET oFolder = oFSO.GetFolder("C:\MyPath")
For Each oFile In oFolder.Files
If oFile.Attributes And 2 Then
WScript.Echo oFile.Path & " is Hidden"
End If
Next
should give you a list of hidden files.
Maybe you could show is more of your code. |
| Carefree |
Posted - 19 February 2011 : 03:17:30 I've got it pulling files, directories, sub-directories; that's not an issue. The problem is in some hidden, unspecified files which do not want to cooperate with the FSO. |
| Doug G |
Posted - 19 February 2011 : 00:40:58 I don't know if this is useful, and it's a VB example not vbscript. It's an example of directory recursion using the filesystem object.
http://support.microsoft.com/kb/185601
|
| Carefree |
Posted - 18 February 2011 : 22:53:33 I've tried that. Tried setting all permissions on the next "logical" file to be hit, same results. The program works from root-through on every drive that isn't a system drive, provided that there are no pagefiles or recycle bins.
BTW to eliminate automatically created recycle bins in non-system drives, first delete the recycle bin, then create a 0-byte text file, name it "Recycler", and finally set its attributes to system file, read-only, hidden. That'll prevent windows from recreating an unwanted/unused trash can.
Of course, if you do that - files you delete are just gone ... not in a trash can to be recovered or emptied. |
| AnonJr |
Posted - 18 February 2011 : 08:41:17 Yeah, but if you have a running list of the names before it, you know what files it isn't. That can help in narrowing down the problem. |
| Carefree |
Posted - 18 February 2011 : 06:13:53 The response.write method won't work here. If it doesn't read the file, it doesn't get a name. |
| kyodai |
Posted - 17 February 2011 : 16:10:13 Without trying myself I'd instantly think of Response.Write" Item name " & objItem.Name
Otherwise i can only think of Try/Catch to debug this. Maybe the sever log will reveal more... |
|
|