Re: Bypass folders without file permissions by Tony
Tony
Thu Jun 26 20:59:54 CDT 2008
Hi Pegasus
here is the code. there is problem when touch with unauthorized folders.
******************************************************
dim Qword, Qexcel, Qaccess
Set objFSOc = CreateObject("Scripting.FileSystemObject")
set objdriveC = objFSOc.getfolder("C:\Documents and Settings")
Qword = 0
Qexcel = 0
Qaccess = 0
Countfiles(objdriveC)
msgbox(Qword & " - " & Qexcel & " - " & Qaccess)
sub Countfiles(objDrive)
on error resume next
for each objfolder in objDrive.subfolders
if objfolder.name <> "Program Files" and objfolder.name <> "Default User"
and objfolder.name <> "RECYCLER" and objfolder.name <> "All Users" and
objfolder.name <> "Media Player" and objfolder.name <> "System Volume
Information" and objfolder.name <> "NetworkService" and objfolder.name <>
"MSOCache" and objfolder.name <> "LocalService" then
set objfiles = objfolder.files
for each objfile in objfiles
if right(objfile.name, 3) = "doc" or right(objfile.name, 4) = "docx"
then
QWord = Qword + 1
elseif right(objfile.name, 3) = "xls" or right(objfile.name, 4) = "xlsx"
then
Qexcel = Qexcel + 1
elseif right(objfile.name, 3) = "mdb" or right(objfile.name, 5) = "accdb"
then
Qaccess = Qaccess + 1
end if
next
set objfiles = nothing
Countfiles objfolder
end if
next
end sub
**********************************************************
"Pegasus (MVP)" <I.can@fly.com.oz> ¼¶¼g©ó¶l¥ó·s»D:ud6rit31IHA.5664@TK2MSFTNGP02.phx.gbl...
>
> "Tony WONG" <x34@netvigator.com> wrote in message
> news:e%23J9s121IHA.2068@TK2MSFTNGP05.phx.gbl...
>>i have a vbs to count number of doc files, like this
>> for each folder in folders .... next
>>
>> the script is completely ok to count files in the folders with file
>> rights permission.
>>
>> however, i try to run it in other folders without file rights, like
>> c:\documents and settings\OtherUser.... it has a script error
>>
>> then i use "on error resume next" to try to bypass the folder
>>
>> the script can be finished. but the count calculation is completely
>> wrong. funny is that it return result of 1732 doc files but i don't have
>> permission to look into the folder.
>>
>> my question is how can i bypass the folder which i don't have file
>> permission.
>>
>> my script is supposed to loop through all the folders in a drive.
>>
>> Thanks a lot.
>>
>> tony
>
> Sorry, can't tell without seeing your script.
>