mrsmileyns
asked on
Limit Windows path and file name length.
Is there a utility or policy that can limit users from creating a path and filename combination that exceeds a specific threshold i.e 255 chars or whatever I specify? I am having some issues with my users creating paths and file names that are 280 + chars. This invariably leads to problems. Is there a way we can stop them from doing this through a policy of some sort...either native MS or third party? We are running a 2003 shop with XP clients. Thanks.
I am unaware of third-party tools that will accomplish this (maybe someone else will pipe in), but I know that it can't be done natively within Windows. This is a common request, but at the moment "user education" is your only refuge. :-(
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Just a shoot in the dark ;)
Any path can be converted to 8.3 format which is in fact shorter than this limit.
Any path can be converted to 8.3 format which is in fact shorter than this limit.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
jkr...where do I specifiy those settings? In enviromnet variables? I am not entirely sure what you are refering to.
This is not a setting. You wrote "I am having some issues with my users creating paths and file names that are 280 + chars" - using the above naming conventions, you can easily deal with those paths.
ASKER
I see - now that I reread your comment it makes more sense - if users put the \\?\ at the start of the path it will work beyond 255 or 260 chars as long as each "section" of the path is not beyond MAX PATH. I think I understand. It is not entirely what I am looking to do but it is VERY good to know and something I was not aware of. Thank you.
I am backing up my windows 2003 user folder on an XP backup server. If a user has a file path longer than 255 char, the backup will hang.
I wrote this simple vbs to scan my user directory on the 2003 server.
I works well for me.
I wrote this simple vbs to scan my user directory on the 2003 server.
I works well for me.
'***************************************************************************************************
'* author Bertrand Vogel *
'* this script will create a log (longpath.txt) of the paths exceeding 250 characters *
'***************************************************************************************************
Dim objFSO, objFileCopy, strPath, strfilepath, objFolder, strDirectory, filesys
Set WshShell = WScript.CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set objFSO = CreateObject("Scripting.FileSystemObject")
set filesys=CreateObject("Scripting.FileSystemObject")
'strpath could be hard coded here (ie: strpath = "d:\users") in stead of opening the input box.
strPath = InputBox("Enter Folder Path you want to scan (ie d:\users): ")
Set fOut = oFSO.CreateTextFile("longpath.txt", True)
DoStuff oFSO.GetFolder(strPath).Path
Sub DoStuff(sDir)
'*******************************************
'********** set path lenght here ***********
'*******************************************
if len(sdir) > 250 then
fOut.WriteLine sDir
end if
Set oDir = oFSO.GetFolder(sDir)
For Each i In oDir.Files
path11=instr(sdir, "\") + 1
path2= mid(sdir,path11)
path20=instr(path2, "\")-1
if path20 > 0 then
path21=left(path2,path20)
end if
'*******************************************
'********** set path lenght here ***********
'*******************************************
if len(sdir & "\" & i.Name) > 250 then
fOut.WriteLine ""
fOut.WriteLine "length of the following path is " & len(sdir & "\" & i.Name)
fOut.WriteLine sdir & "\" & i.Name
end if
Next
For Each i In oDir.SubFolders
DoStuff i.Path
Next
End Sub
WshShell.Run "notepad.exe longpath.txt"