Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Removing system files

Reply
Thread Tools

Removing system files

 
 
Kaldrenon
Guest
Posts: n/a
 
      07-04-2007
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

 
Reply With Quote
 
 
 
 
Lambik
Guest
Posts: n/a
 
      07-04-2007
"Kaldrenon" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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


 
Reply With Quote
 
 
 
 
Kaldrenon
Guest
Posts: n/a
 
      07-04-2007
On Jul 4, 2:52 pm, "Lambik" <(E-Mail Removed)> 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.

 
Reply With Quote
 
Lambik
Guest
Posts: n/a
 
      07-04-2007
"Kaldrenon" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> On Jul 4, 2:52 pm, "Lambik" <(E-Mail Removed)> 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>.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAT32 file system - Adding and removing files. superhac007@gmail.com C Programming 6 09-18-2009 05:15 PM
Removing GPO setting from XP machine after removing from Domain Piet Slaghekke Computer Support 4 01-02-2007 08:58 PM
removing a namespace prefix and removing all attributes not in that same prefix Chris Chiasson XML 6 11-14-2006 05:08 PM
System.Security.SecurityException: Error de solicitud de permiso de tipo System.Net.WebPermission, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089. Luis Esteban Valencia ASP .Net 0 07-14-2005 01:43 PM
Removing child domains after system restore =?Utf-8?B?UGhpbA==?= MCSE 4 02-13-2004 04:45 PM



Advertisments