Removing system files

K

Kaldrenon

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
 
L

Lambik

Kaldrenon said:
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
 
K

Kaldrenon


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

Lambik

Kaldrenon said:
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>.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top