Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
First off why does this only occur with %SystemRoo­t%

Other environment variables can be put in path components and CleanPath will handle them just fine. What it does special with %SystemRoot% is that if you put a directory in your $ENV{PATH} that is a subdirectory of %SystemRoot% without saying "%SystemRoot%", then CleanPath changes it to use %SystemRoot%. So "CleanPath C:\Windows\system32\trojans" will actually put "%SystemRoot%\trojans" into your path.

This feature was mostly added because the big motivation for writing this script was that a coworker had written a script to flush $ENV{PATH} changes into the registry and done a bad job of it, not realizing that $ENV{PATH} doesn't match what gets put in the registry for several reasons (notably user-specific path components and expansion of %SystemRoot%) so I wanted to clean this mess up easily (quite a few system had been corrupted by this before anyone noticed). If you use %SystemRoot%, then those entries in your $ENV{PATH} continue to work even if the drive letter for that partition changes on your when you reboot (and I was working in situations where this wasn't that uncommon of a situation); that's why those entries are done that way.

I wasn't too worried about the bug you pointed out because just running CleanPath twice takes care of it. I didn't include your fix at first because I needed to look over how I was using %GoodPath to convince myself that there were no problems with that fix. I just now incorporated your fix (slightly differently) as I was making some other minor updates. Thanks!

- tye        

In reply to Re^2: CleanPath (updated) by tye
in thread CleanPath by tye

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others wandering the Monastery: (4)
    As of 2020-10-25 00:07 GMT
    Find Nodes?
      Voting Booth?
      My favourite web site is:

      Results (248 votes). Check out past polls.