Can't delete or modify file/directory with reserved names

AID: 1808
  • Status: Published

1250 points

  • Bykaerez
  • TypeFAQs
  • Posted on2009-10-20 at 05:40:25
Some malware (including virus's and other types of programs with bad intentions) as well as some hardening programs and utility's sometimes create files and directorys with illegal names.

Why "illegal" ?
Because some names such as LPT1, LPT2, LPTx, PRN, CON and more are reserved as
they have a unique meaning to the operating system.

Trying to rename/delete/modify a file or directory with such an illegal file name will return
Access Denied
                                    
1:

Select allOpen in new window



LPT1 (LPTx) for example is usually the parallel port on the computer,
CON is short for console, PRN is printer, etc...

So if you see a directory or file such as
c:\LPT1
                                    
1:

Select allOpen in new window


And can't seem to be able and rename or delete it, the reason is that
some names such as PRN, LPTx (LPT1, LPT2, ...), CON and more are system reserved.

The solution is straight forward, to rename for example:
ren \\.\c:\LPT1 c:\NNN
                                    
1:

Select allOpen in new window



The reason why the line above would work is because of it's prefix:
\\.\
                                    
1:

Select allOpen in new window


This is a back door of sorts that causes Windows not to check for illegal file names, this would also
prevent certain commands and is the easiest method to get rid of such files and directory's without disk hex editing.

If you still can access it the file/directory either has attributes turned on, turn off using:
attrib -s -h -r \\.\c:\LPT1
                                    
1:

Select allOpen in new window



The file/directory might not provide have ACL rights to allow you access, to grant access:
cacls \\.\c:\LPT1 /t /c /g %username%:f
                                    
1:

Select allOpen in new window



It is highly recommended to have an updated Windows environment (patch's and updates from Microsoft) and have an updated Antivirus program on your system at all times.

GOOD LUCK!
Asked On
2009-10-20 at 05:40:25ID1808
Tags

windows

,

illegal

,

file

,

directory

,

con.lpt

,

prn

,

delete

,

modify

,

reserved

Topic

Miscellaneous Security

Views
739

Comments

Add your Comment

Please Sign up or Log in to comment on this article.

Join Experts Exchange Today

Gain Access to all our Tech Resources

Get personalized answers

Ask unlimited questions

Access Proven Solutions

Search 3.2 million solutions

Read In-Depth How-To Guides

1000+ articles, demos, & tips

Watch Step by Step Tutorials

Learn direct from top tech pros

And Much More!

Your complete tech resource

See Plans and Pricing

30-day free trial. Register in 60 seconds.

Loading Advertisement...

Top Misc Security Experts

  1. breadtan

    145,843

    Master

    3,100 points yesterday

    Profile
    Rank: Genius
  2. Russell_Venable

    38,663

    0 points yesterday

    Profile
    Rank: Wizard
  3. ahoffmann

    27,636

    0 points yesterday

    Profile
    Rank: Genius
  4. richrumble

    25,321

    0 points yesterday

    Profile
    Rank: Genius
  5. DaveHowe

    17,129

    2,000 points yesterday

    Profile
    Rank: Genius
  6. SSharma

    16,184

    0 points yesterday

    Profile
    Rank: Genius
  7. younghv

    12,906

    0 points yesterday

    Profile
    Rank: Genius
  8. DaveBaldwin

    12,728

    0 points yesterday

    Profile
    Rank: Genius
  9. Tolomir

    12,268

    0 points yesterday

    Profile
    Rank: Genius
  10. ve3ofa

    11,032

    0 points yesterday

    Profile
    Rank: Genius
  11. dvt_localboy

    10,600

    0 points yesterday

    Profile
    Rank: Sage
  12. pand0ra_usa

    10,600

    0 points yesterday

    Profile
    Rank: Guru
  13. rpggamergirl

    10,364

    0 points yesterday

    Profile
    Rank: Genius
  14. abbright

    10,292

    0 points yesterday

    Profile
    Rank: Guru
  15. kode99

    9,900

    0 points yesterday

    Profile
    Rank: Genius
  16. erniebeek

    9,250

    0 points yesterday

    Profile
    Rank: Genius
  17. slemmesmi

    8,200

    0 points yesterday

    Profile
    Rank: Guru
  18. motnahp00

    8,102

    0 points yesterday

    Profile
    Rank: Sage
  19. CoccoBill

    7,364

    0 points yesterday

    Profile
    Rank: Sage
  20. giltjr

    7,187

    900 points yesterday

    Profile
    Rank: Genius
  21. tedbilly

    7,000

    0 points yesterday

    Profile
    Rank: Genius
  22. arnold

    6,800

    0 points yesterday

    Profile
    Rank: Genius
  23. MASQUERAID

    6,800

    0 points yesterday

    Profile
    Rank: Genius
  24. ZShaver

    6,800

    0 points yesterday

    Profile
    Rank: Master
  25. madunix

    6,624

    0 points yesterday

    Profile
    Rank: Sage

Hall Of Fame