Windows cannot copy file. The filename or extension is too long

A

Ahmed

hey
we are having this new problem in our labs that windows create the mandatory
profile which is located locally in the same workstation becouse there is a
file thats too long in the temporary internet files. the profile should be
deleted on log off but it does not for a reason that i dont know or becouse
it is locked. i tried using the UPHclean up "both the old the new and the
beta" and it didnt work. i tried to put a log off script to delete the
profile but it works only when we log in as admin. this problem is killing
me. any help will be appriciated.
 
S

smlunatick

hey
we are having this new problem in our labs that windows create the mandatory
profile which is located locally in the same workstation becouse there isa
file thats too long in the temporary internet files. the profile should be
deleted on log off but it does not for a reason that i dont know or becouse
it is locked. i tried using the UPHclean up "both the old the new and the
beta" and it didnt work. i tried to put a log off script to delete the
profile but it works only when we log in as admin. this problem is killing
me. any help will be appriciated.

What is the filename? There is a filename size limt.
 
P

Pegasus [MVP]

Ahmed said:
hey
we are having this new problem in our labs that windows create the
mandatory
profile which is located locally in the same workstation becouse there is
a
file thats too long in the temporary internet files. the profile should be
deleted on log off but it does not for a reason that i dont know or
becouse
it is locked. i tried using the UPHclean up "both the old the new and the
beta" and it didnt work. i tried to put a log off script to delete the
profile but it works only when we log in as admin. this problem is killing
me. any help will be appriciated.

I would rename the file with the exessively long name.
 
A

Ahmed

hey
sorry for not answering fast coz i thought i would get an e mail when
someone answers but i didnt. any way it does not matter what the file name is
coz even if i delete it when any other user logs in and get to the same web
site it will come back and we get the same problem. now you will ask which
website and i will say there are many web site that will leave some jpg files
with a very long file names. and i have 5 labs with 20 computer in each so it
is impossible to log in every computer and delete the temparory internet
files or delete the profile.
 
A

Ahmed

hey
sorry for not answering fast coz i thought i would get an e mail when
someone answers but i didnt. any way it does not matter what the file name is
coz even if i delete it when any other user logs in and get to the same web
site it will come back and we get the same problem. now you will ask which
website and i will say there are many web site that will leave some jpg files
with a very long file names. and i have 5 labs with 20 computer in each so it
is impossible to log in every computer and delete the temparory internet
files or delete the profile.
 
P

Pegasus [MVP]

In newsgroups you will never receive a reply by personal EMail. Replies made
by respondents will only be visible in the newsgroups themselves.

Unfortunately you are restricted to a total path+file name length of 260
characters. You will have to rename/delete the files with the excessively
long names on each and every PC. There is no other way.
 
A

Ahmed

this is what i am talking about. i dont get any notification when there is a
response on my quesion
 
A

Ahmed

hello pegasus
are u serious. u want me to go around 300 computers and delete the profile
or rename the filename. this is far from being a solution. and why it happens
at all the mandatory profile should be deleted on log off.
 
P

Pegasus [MVP]

No, you don't "go around to 300 PCs" but if you are responsible for 300 of
them then it is imperative that you acquire skills in scripting and managing
them remotely. Administrators without such skills are ineffective. Here are
a couple of methods to resolve the current issue:
- Include a suitable "delete" instruction in your logon script.
- Execute a batch file from your console that gets the 300 machine names
from a text file, then deletes the offending file remotely.
 
A

Ahmed

1-a delete instruction cannot be executed in logon script coz the user does
not have previlidges and you cannot delete the user profile while he is
logged in. you may say log off script and for the same reason the user does
not have enough previliges to delete the profile "you can try it" coz i
already tried it. it works if an admin logs in and logs out.
2- regarding the second part "batch file"
the computers are distributed on 2 buildings in different labs and the
problem happens when the users visit some website so i dont know when the
problem happens and in which computer and i cant run the batch file everytime
a user logs off.
i already have all those solutions that you talked about but they are not
effecient acctually. i have a dosen of scripts now but all needs admin rights
to run att log off.
 
P

Pegasus [MVP]

*** See below.

Ahmed said:
1-a delete instruction cannot be executed in logon script coz
(=because) the user does not have previlidges and you cannot
delete the user profile while he is logged in. you may say log off
script and for the same reason the user does not have enough
previliges to delete the profile "you can try it" coz (=because)
i already tried it. it works if an admin logs in and logs out.
*** This is getting a little puzzling. If the user does not have
*** sufficient privileges to delete a file that resides in his own
*** profile folder, how did he create it in the first place? Is
*** it perhaps that the file has the read-only attribute set, which
*** needs to be removed before he can delete the file?
2- regarding the second part "batch file"
the computers are distributed on 2 buildings in different labs and the
problem happens when the users visit some website so i dont know when the
problem happens and in which computer and i cant run the batch file
everytime
a user logs off.
*** You can insert an instruction like this one into the logon script:
*** if exist "%UserProfile%\...\Long File Name.url" del
""%UserProfile%\...\Long File Name.url"
*** This does not work because the file name is too long then subst.exe
*** can be used to shorten the path.
i already have all those solutions that you talked about but they are not
effecient acctually. i have a dosen of scripts now but all needs admin
rights
to run att log off.
*** I would not worry about the solutions being efficient or not, as
*** long as they are effective (=as long as they work).
 
A

Ahmed

helloo again
first of all i would like to thank you for the effort in trying to help me.
second i solved in anther way.
i put the delete script in the startup script instead of the log off script
and i removed the log off from shutdown menu so the user will choose to
restart always and i will be sure that the profile is deleted at start up and
it works.

the problem is that it is not only one file that cause the problem so i
cannot use

if exist "%UserProfile%\...\Long File Name.url" del

there are many website that cause the problem with files with different
extensions like url or jpg .... etc

best regards
 
P

Pegasus [MVP]

While I accept that there may be more than one web site that generates
exessively long file names, I do not think that there are many of them. They
tend to be malicious sites that want to prevent visitors from deleting the
files they generate. I suspect that some of your users visit sites that they
should not visit.

One way to deal with the issue is to run a script at logon time to identify
all temporary internet files with excessively long names. When you have the
list then you can examine it and discuss the issue with the users. The
script below will create such a list. Depending on the number of temporary
internet files, it might take half a minute or more to execute. Do not
retype the script - use copy and paste instead. The result will be visible
in c:\LongNames.txt

@echo off
set Len=240
if exist c:\LongNames.txt goto :eof
echo %date% %time:~0,5% %UserName% %ComputerName% > c:\LongNames.txt
set Scr=c:\TempVBS.vbs
set VB=echo^>^>%Scr%
cd 1>nul 2>%Scr%
%VB% Set oFSO = CreateObject("Scripting.FileSystemObject")
%VB% Set oWshShell = CreateObject("WScript.Shell")
%VB% sFolder = oWshShell.ExpandEnvironmentStrings( _
%VB% "%UserProfile%\Local Settings\" _
%VB% ^& "Temporary Internet Files\Content.ie5")
%VB% Set oFolder = oFSO.GetFolder(sFolder)
%VB% For Each oSubFolder In oFolder.SubFolders
%VB% For Each oFile In oSubFolder.Files
%VB% sPath = oFile.path
%VB% if len(sPath) ^> %Len% then WScript.Echo sPath
%VB% Next
%VB% Next
cscript //nologo %Scr% >> c:\LongNames.txt
del %Scr%
 
A

Ahmed

Thanx again for the script. i just made a small change in it just make it
easier for me i change the line
if len(sPath) ^> %Len% then WScript.Echo sPath
into
if len(sPath) ^> %Len% then oFile.delete
hope you dont mind and i ran it as vbscript att log off. i will put it in
one of my labs 2moro to see if it works coz it worked for me today in my test
workstation.
some of the website that made the problem are the BBC , the university home
page and youtube and others.
 
P

Pegasus [MVP]

Ahmed said:
Thanx again for the script. i just made a small change in it just make it
easier for me i change the line
if len(sPath) ^> %Len% then WScript.Echo sPath
into
if len(sPath) ^> %Len% then oFile.delete
hope you dont mind and i ran it as vbscript att log off. i will put it in
one of my labs 2moro to see if it works coz it worked for me today in my
test
workstation.
some of the website that made the problem are the BBC , the university
home
page and youtube and others.

No, I don't mind at all you changing my script - in fact I'm glad you seized
the initiative. On the other hand you need to be aware that deleting files
without user confirmation can cause problems. During the testing phase I
would probably maintain a log like so:

iLen=240
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oWshShell = CreateObject("WScript.Shell")
sFolder = oWshShell.ExpandEnvironmentStrings( _
"%UserProfile%\Local Settings\" _
& "Temporary Internet Files\Content.ie5")
Set oFolder = oFSO.GetFolder(sFolder)
For Each oSubFolder In oFolder.SubFolders
For Each oFile In oSubFolder.Files
sPath = oFile.path
if len(sPath) > iLen then
WScript.Echo sPath
oFile.Delete sPath
end if
Next
Next

Remember to invoke the script like so:
cscript //nologo c:\LongNames.vbs >> "%UserProfile%\My
Documents\LongNames.txt"
 
D

David H. Lipman

From: "leslysab said:
Ahmed wrote on 10/28/2009 05:03 ET :
Download Long Path Tool it will do the job for you guaranteed fix

Do not follow the suggesting of this spammer replying to a post from 2009 !

One can always use the SUBSTitute command and create a drive letter within the path and
manipulate the file and or path to be withing the NTFS max. length.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top