这是我写的一个代码,它的用处是计算出当前目前内的拥有hide 和system属性的文件并显示出来,从我的测试来看两个计算代码是正常的,但最后面两个if判断句却出现错误,在当前目录中无论存不存在system和hide属性文件或文件夹都不会运行msgbox函数,我自己有一个解决办法,但不是很好,希望有坛友给出问题的根源。谢谢。- dim ws,fs,current_path_files,current_path_subfolders,att,files_sum,subfolders_sum
- 'on error resume next
-
- set ws=wscript.createobject("wscript.shell")
- set fs=wscript.createobject("scripting.filesystemobject")
-
- set current_path_files=fs.getfolder(ws.CurrentDirectory).files
- set current_path_subfolders=fs.getfolder(ws.CurrentDirectory).subfolders
- '==========================================================================
- for each file in current_path_files
- 'ignore the shortcut and link
- att=file.attributes
- if att=4+2 or att=4+2+1 or att=4+2+32 or att=4+2+32+1 then
- files_sum=files_sum & file.name & vbnewline
- end if
- next
-
- for each subfolder in current_path_subfolders
- 'ignore the shortcut and link
- att=subfolder.attributes
- if att=4+2 or att=4+2+16 or att=4+2+16+1 then
- subfolders_sum=subfolders_sum & subfolder.name & vbnewline
- end if
- next
- '==========================================================================
- if files_sum <> "" then
- msgbox files_sum,,"Exist Hide and System file(s):"
- end if
-
- if folders_sum <> "" then
- msgbox subfolders_sum,,"Exist Hide and System folder(s):"
- end if
复制代码
[ 本帖最后由 s700800900 于 2010-6-20 23:48 编辑 ] |