Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   Removing system files (http://www.velocityreviews.com/forums/t903717-removing-system-files.html)

Kaldrenon 07-04-2007 12:30 AM

Removing system files
 
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


Lambik 07-04-2007 06:52 PM

Re: Removing system files
 
"Kaldrenon" <kaldrenon@gmail.com> wrote in message
news:1183509047.677601.138640@57g2000hsv.googlegro ups.com...
> 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



Kaldrenon 07-04-2007 07:10 PM

Re: Removing system files
 
On Jul 4, 2:52 pm, "Lambik" <lam...@kieffer.nl> 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.


Lambik 07-04-2007 08:11 PM

Re: Removing system files
 
"Kaldrenon" <kaldrenon@gmail.com> wrote in message
news:1183576248.048764.188700@w5g2000hsg.googlegro ups.com...
> On Jul 4, 2:52 pm, "Lambik" <lam...@kieffer.nl> 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>.




All times are GMT. The time now is 10:41 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.