error "800A004C" with too long path with recursive folder serarch

44 Views Asked by At

I had tried to change the target path of shortcut at once with vbscript. Nevertheless we got an error 800A004C because of its path over the windows limitation (<=260).

Now, I need to skip/ignore the too long path.

    Private Sub validateShortcut(dirpath)
        if len(dirpath) > 260 Then
            Exit Sub
        End if
    
        Dim fso, folder
        Set fso = CreateObject("Scripting.FileSystemObject")
        Set folder = fso.GetFolder(dirpath)
        
        Dim WshShell
        Dim oShellLink
        Set WshShell = WScript.CreateObject("WScript.Shell")
        
        Dim file
        txtobj.WriteLine("point1")
        For Each file In folder.Files   '800A004C will occur at here if path length of "file" over 260
            txtobj.WriteLine("point2")
            ChangeShortcutPath(..)
        Next
        
        Dim subfolder
        For Each subfolder In folder.SubFolders
            If 'attributes is Directory
                Call validateShortcut(subfolder.path)
        Next
    End Sub

    Private Sub ChangeShortcutPath(FilePath)
        ..
    End Sub

I've just investigated the details. but I could not do anything for resolve. In my case, we can reach the "point1" but not the "point2" when length of "dirpath" is 258.

0

There are 0 best solutions below