Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

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?

----
Coyote

  • 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.

    ----
    Coyote

      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.

    —John

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://114412]
Approved by root
help
Chatterbox?
[Discipulus]: if i had to go to psycho i need to ask why i always end with over complex datastructure: now i have an HoHoAoH in my object
[Discipulus]: i will need to handle by reference later on
[Eily]: kinda sounds like father Christmas is late
[hippo]: (asking because I'm sure you said before about learning English) Did you know there are 2 different words for smaller quantities in English? They are "less" and "fewer". Fewer applies to a number of discrete things like days.
Eily notes also
[hippo]: So if you don't drink as much milk and not as often you are said to drink less milk on fewer days. Confusing, eh?
[Eily]: same as many/much, few/little

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2018-01-23 09:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How did you see in the new year?










    Results (242 votes). Check out past polls.

    Notices?