Removing system files

Discussion in 'Perl Misc' started by Kaldrenon, Jul 4, 2007.

  1. Kaldrenon

    Kaldrenon Guest

    Hi all.

    A while ago I installed Vista on one of my hard drives (I'm running XP
    Home on the other) but quickly decided that I wasn't going to make the
    switch. Now I want to get rid of the Vista system files, but since
    there are things on the drive that I want to keep (more than I can
    easily transfer to a different hard drive), what I'm trying to do is
    to write a Perl script that uses File::Find to wipe the directories
    that contain system files, leaving the remaining dirs untouched. I
    wrote something that worked, or so I thought, but then I realized that
    it left a large number of system files and the like in place. They're
    the files which say "Access Denied" if I try to del them from cmd.exe
    or Windows Explorer.

    Is there an easy way to override file permissions in Perl? chmod or
    something like it?

    Here's what I already have (it's small enough to be its own SSCCE):

    use File::Find;
    $| = 1;
    $\ = "\n";
    @folders = ("F:/Windows","F:/Program Files","F:/Program Data","F:/
    Users");
    find(\&break_it, @folders);

    sub break_it
    {
    unlink($_) if -f;
    rmdir($_) if -d;
    print $_, " deleted.";
    }

    P.S. I realize that this would be a horrendously unsafe idea if I
    weren't convinced that I don't want these files any more.

    Thanks,
    Andrew
     
    Kaldrenon, Jul 4, 2007
    #1
    1. Advertising

  2. Kaldrenon

    Lambik Guest

    "Kaldrenon" <> wrote in message
    news:...
    > Hi all.
    >
    > A while ago I installed Vista on one of my hard drives (I'm running XP
    > Home on the other) but quickly decided that I wasn't going to make the
    > switch. Now I want to get rid of the Vista system files, but since
    > there are things on the drive that I want to keep (more than I can
    > easily transfer to a different hard drive), what I'm trying to do is
    > to write a Perl script that uses File::Find to wipe the directories
    > that contain system files, leaving the remaining dirs untouched. I
    > wrote something that worked, or so I thought, but then I realized that
    > it left a large number of system files and the like in place. They're
    > the files which say "Access Denied" if I try to del them from cmd.exe
    > or Windows Explorer.
    >

    isn't a Perl problem. http://dougknox.com/xp/tips/xp_undeletable_file.htm
    or
    http://www.theeldergeek.com/delete_undeletable_file.htm
     
    Lambik, Jul 4, 2007
    #2
    1. Advertising

  3. Kaldrenon

    Kaldrenon Guest

    On Jul 4, 2:52 pm, "Lambik" <> wrote:
    > isn't a Perl problem.http://dougknox.com/xp/tips/xp_undeletable_file.htm
    > orhttp://www.theeldergeek.com/delete_undeletable_file.htm


    That's good information to know, but not pertinent to the problem I'm
    having. What you linked to is a cure for "File is in use" errors, but
    the trouble I'm having is "access denied." I've used that trick before
    when files wouldn't delete, claiming that a program was using them
    when none was. It didn't work here. I reran my script after killing
    explorer.exe and nothing happened, no files were deleted.

    I know that access/permission are not due to my using Perl, but I was
    hoping that I would be able to get around them in Perl.
     
    Kaldrenon, Jul 4, 2007
    #3
  4. Kaldrenon

    Lambik Guest

    "Kaldrenon" <> wrote in message
    news:...
    > On Jul 4, 2:52 pm, "Lambik" <> wrote:
    > > isn't a Perl problem.http://dougknox.com/xp/tips/xp_undeletable_file.htm
    > > orhttp://www.theeldergeek.com/delete_undeletable_file.htm

    >
    > That's good information to know, but not pertinent to the problem I'm
    > having. What you linked to is a cure for "File is in use" errors, but
    > the trouble I'm having is "access denied." I've used that trick before
    > when files wouldn't delete, claiming that a program was using them
    > when none was. It didn't work here. I reran my script after killing
    > explorer.exe and nothing happened, no files were deleted.
    >
    > I know that access/permission are not due to my using Perl, but I was
    > hoping that I would be able to get around them in Perl.


    Permissions are queried by "attrib <filename>". If they are readonly then a
    "R" flag should be shown.

    A R C:\tvc.png

    a=archive
    r= read-only

    you can reset it with attrib -r <filename>.
     
    Lambik, Jul 4, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ion
    Replies:
    2
    Views:
    441
  2. Bhanu
    Replies:
    2
    Views:
    1,346
    Roedy Green
    May 5, 2006
  3. Chris  Chiasson
    Replies:
    6
    Views:
    624
    Richard Tobin
    Nov 14, 2006
  4. Adam Salisbury
    Replies:
    0
    Views:
    813
    Adam Salisbury
    Aug 21, 2008
  5. Replies:
    6
    Views:
    1,141
Loading...

Share This Page