Home > Computers and Internet > Get fake directory names to stay away

Get fake directory names to stay away

Previously I posted Getting rid of fake directory names in Windows 7 talking about how to clear the LocalizedResourceName from a user profile, so that way the name of directories in Explorer match the names you’d see in other programs. Certain Windows updates will put the fake directory names back. I have gotten annoyed at periodically clearing the names, so I created a PowerShell script to automatically do it.

$parentDirs= ($env:USERPROFILE,$env:PUBLIC)
foreach ($parentDir in $parentDirs){
$dirs = Get-Item ($parentDir+“\*”);
foreach($dir in $dirs){
$filename = ($dir.FullName +“\desktop.ini”)
$content = Get-Content $filename -ErrorAction Stop;
$newContent = $content | Where-Object {-Not $_.StartsWith(“LocalizedResourceName”)};
if($newContent.Length -lt $content.Length){
Set-Content $filename -Value $newContent
catch [System.Management.Automation.ItemNotFoundException]{ continue; }

To run the script when I log in I created a Scheduled Task. In my Task Scheduler Library I created a task which runs when I log in and has an action of running C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe with the arguments -NonInteractive -File “C:\Users\Public\Documents\RemoveLocName.ps1”.

Now I don’t need to worry about incorrect names being displayed again.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: