Deleting files with “too long filenames” in Windows

If you’re using Microsoft Windows and happen to have a file that has a very long filename, more than 260 characters to be percise, you’re living in a hell… Nothing can be done with it! Unless you use a great little tool of course, Robocopy!robocopy

Robocopy is an old product that comes with Windows since Vista (i think?) an can be accessed via Powershell. The thing with Robocopy is that it’s main purpuse is to copy files in one way or another. It has a feature for Mirroring one folder to another. With that said, what happens when you mirror an empty folder with a folder containing files with names too long? You get two empty folders! :) Life’s good!

The basic command for doing this is:
robocopy.exe c:\My\Empty\Folder c:\Folder\With\Long\Names /MIR

What I used this for was cleaning up the INetCache folder that had gone wild and crazy and gave the users alot of problem.
The script I used to clean this folder was:
Get-ChildItem X:\Profilefolder | foreach {robocopy X:\Empty (“X:\Profilefolder\” + “$_” + “\AppData\Local\Microsoft\Windows\INetCache”) /MIR}

This just lists all entries in X:\Profilefolder and handles each entry with a robocopy command that is mirroring the empty folder with the INetCache folder.



Drop down menus alignment

I recently came across a funny scenario where, in a XenDesktop 7.1 environment, the drop down menus are on the wrong side of the cursor. The reason for this is the Tablet PC functionality in Windows 7+ where it looks at what type of display you are using and try to give you the most user friendly experience, even though you don’t have a Tablet PC. Now, because we’re in a XenDesktop environment it turned out that the display is “Unkown”, therefor it does a little bit whatever instead of using the most resonable option…

To fix this for a single user you do the following:

1. Run this command: shell:::{80F3F1D5-FECA-45F3-BC32-752C152E456E}

2. Click on Other

3. Change Handedness from Right handed to Left handed

4. Click on OK and you’re done!


To fix this via GPO do the following in the registry:

Add or Update the property MenuDropAlignment (REG_SZ) and set 0 to drop on the right side of the mouse, and 1 to drop on the left side of the mouse. You need to add/update the property on both of these locations:

HKCU\Control Panel\Desktop

HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows