Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Finding hidden and system files with File::Find (win32)

by Coyote (Deacon)
on Sep 25, 2001 at 00:19 UTC ( #114412=perlquestion: print w/replies, xml ) Need Help??
Coyote has asked for the wisdom of the Perl Monks concerning the following question:

I'm in the process of cleaning up some network shares hit by the nimda virus/worm and the virus attaches itself as a trojan to a couple of dll and exe files as well as copying *.eml and *.nws files everywhere. I'm using File::Find to recurse through the infected system's file system and clean up the mess. My script is picking up the *.eml and *.nws files without any problem, however I'm missing the executable files which are flagged with the hidden and system file system attributes. Is there any way to find files with the hidden and system attribute set on a Win32 system?


  • Comment on Finding hidden and system files with File::Find (win32)

Replies are listed 'Best First'.
(tye)Re: Finding hidden and system files with File::Find (win32)
by tye (Sage) on Sep 25, 2001 at 01:09 UTC

    I've never seen readdir nor glob skip readonly, system, nor hidden files in Perl under Win32. My quick testing shows hidden and system files showing up via both of those methods just fine. So I don't see how File::Find could be skipping those unless it contains code to do that, which I don't see.

    Perhaps the problem is elsewhere?

            - tye (but my friends call me "Tye")
Update: Finding hidden and system files with File::Find (win32)
by Coyote (Deacon) on Sep 25, 2001 at 02:06 UTC
    Update: Not suprisingly, tye is correct about the behavior of readdir, glob, and File::Find. Running a script similar to my nimda repair script on a Win2k pro box shows files flagged with the system and hidden attributes.

    Running the same script on a Novell Netware server doesn't show hidden and/or system flagged files consistantly. The problem seems to be Netware related rather than perl related. Using the Novell flag command to remove the hidden and system attributes on the effected files before running the script, took care of the problem. I will try to reproduce the problem with files that are less dangerous and update this node with my solution.

    Thanks to everyone who responded.


      can someone point me in the right direction on how to use the Win32::API I'm in the same boat as Coyote, but the script I wrote using File::Find doesn't work quite right for some folders where I dont have "rights". So for now I'd like the script to just skip those folders, any advice?
Re: Finding hidden and system files with File::Find (win32)
by John M. Dlugosz (Monsignor) on Sep 25, 2001 at 00:39 UTC
    Perhaps you could override the "built in" CORE meaning of opendir/readdir to have a version that sees all files, or allows you to specify flags somehow.

    Or you could use the commandline or GUI shell to turn off the flags on all files, before running your script.

    As for "can it be done", yes, use Win32 API functions instead of opendir/readdir or File::Find which uses those. Looks like Win32API::File doesn't have them. But Win32::API can do anything.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://114412]
Approved by root
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (8)
As of 2018-06-25 11:53 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.