"Windows cannot copy file ... to location ..."

Last edited on

Symptoms

You may get the following error message when trying to log on to Windows:

"Windows cannot copy file ... to location .... Possible causes of this error include network problems or insufficient security rights. If this problem persists, contact your network administrator.

DETAIL - The filename or extension is too long.

More information

The Eclipse-based Squish IDE defaults to storing the workspace in the roaming profile area which might exceed the maximum path length and thus cause this error upon login.

Solution

A quick solution is to delete the files and folders reported by Windows.

To delete files and folders in overly long paths you can write a little file "delete_something.js" with this content:

var fso = new ActiveXObject("Scripting.FileSystemObject");
n = "\\\\?\\C:\\Users\\MyUser\\some_path\\Folder_that_should_be_deleted";
fso.DeleteFolder(n);

When you double click the file "delete_something.js" with Windows Explorer or execute it in cmd.exe it should now be able to delete the specified, excessively long folder.

Microsoft explains the above "\?..." notation for paths at Naming Files, Paths, and Namespaces .

To avoid that the Squish IDE creates its workspace in that %APPDATA% roaming path create a shortcut of "<squish_dir>/bin/ide/squishide.exe" (do not use "<squish_dir>/bin/squishide.exe", that will not work).

Then right click on the shortcut and open its properties. In the target field append...

-data "%APPDATA%\..\Local\squish_workspace"

...to what is already being displayed. So the end result should be similar to...

C:\something\bin\ide\squishide.exe -data "%APPDATA%\..\Local\squish_workspace"

Then please use this shortcut to open the Squish IDE.

Microsoft support knowledge base: User profile cannot be loaded with Event ID 1509, DETAIL - The filename or extension is too long