This is really driving me crazy.
In one cell, I change $Path by removing from it un-needed paths that I do not want for the duration of a computation I will be doing.
Immediatly after, in new cell, I type $Path and see it was changed ok.
Now, I open a new cell, and do the same. I type $Path again, and now I see some of the Paths I removed are back again! Here is a screen shot from my notebook now

You can see the variable $Path now has changed, on its own.
This is what I type
$Path =DeleteCases[$Path, "C:\\Users\\me"];
$Path =DeleteCases[$Path, "."];
$Path =DeleteCases[$Path,"C:\\Program Files\\Wolfram Research\\Mathematica\\8.0.4\\AddOns\\LegacyPackages"];
$Path =DeleteCases[$Path,"C:\\Users\\me\\AppData\\Roaming\\Mathematica\\Autoload"];
$Path =DeleteCases[$Path,"C:\\Users\\me\\AppData\\Roaming\\Mathematica\\Kernel"];
$Path =DeleteCases[$Path,"C:\\Users\\me\\AppData\\Roaming\\Mathematica\\Applications"];
$Path =DeleteCases[$Path,"C:\\ProgramData\\Mathematica\\Applications"];
$Path =DeleteCases[$Path,"C:\\ProgramData\\Mathematica\\Autoload"];
$Path =DeleteCases[$Path,"C:\\ProgramData\\Mathematica\\Kernel"];
$Path=DeleteCases[$Path,"C:\\Program Files\\Wolfram
Research\\Mathematica\\8.0.4\\Documentation\\English\\System"];
Then in new cell
$Path
Then in new cell the same. And now the $Path has been reset.
I noticed this when I was calling Leonid function he posted, and in it, it uses $Path, but I noticed I was getting packages that should not show up since I changed the $Path before calling it.
This is really strange. I am using V 8.0.4 on windows 7
edit
Just installed version 9. Not able to reproduce this. Using the same PC, same notebook, same steps. So it looks like, whatever it was, is fixed in Version 9.
Block[{$Path= DeleteCases[$Path,...]},...]around the function, to get rid of those directories dynamically. – Leonid Shifrin Nov 28 '12 at 18:41