144 lines
4.1 KiB
PowerShell
144 lines
4.1 KiB
PowerShell
# Sprawdź klucz rejestru odpowiadający za obsługę długich ścieżek
|
|
# Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name LongPathsEnabled
|
|
|
|
$rootDir = "C:\test_tk_glebokosc"
|
|
$dirName = "dir"
|
|
|
|
$counter = 1
|
|
$currentDir = $rootDir
|
|
$limit = 300
|
|
|
|
while ($true) {
|
|
$newDir = Join-Path -Path $currentDir -ChildPath ($dirName + $counter)
|
|
try {
|
|
New-Item -Path $newDir -ItemType Directory -ErrorAction Stop | Out-Null
|
|
#Write-Host "Utworzono katalog: $newDir"
|
|
$currentDir = $newDir
|
|
$counter++
|
|
#if ($counter % 100 -eq 0) {
|
|
# "Głębokość $newDir"
|
|
#}
|
|
if ($counter -eq $limit) {
|
|
break
|
|
}
|
|
} catch {
|
|
Write-Host "Nie można utworzyć katalogu: $newDir. Limit filesystemu osiągnięty?"
|
|
break
|
|
}
|
|
}
|
|
|
|
$newDir
|
|
"Utworzono ścieżkę o długości: $($newDir.Length) znaków | Przerwane przy ilości: $($counter) zagnieżdżeń."
|
|
Remove-Item $rootDir -Recurse -Force
|
|
|
|
$rootDir = "C:\test_tk_nazwa_folderu"
|
|
$dirName = "dir"
|
|
$fileName = "file"
|
|
|
|
$counter = 1
|
|
$maxDirLength = 0
|
|
$maxFileLength = 0
|
|
|
|
while ($true) {
|
|
$newDir = Join-Path -Path $rootDir -ChildPath ($dirName + ("a" * $counter))
|
|
try {
|
|
New-Item -Path $newDir -ItemType Directory -ErrorAction Stop | Out-Null
|
|
$maxDirLength = $counter
|
|
$counter++
|
|
} catch {
|
|
break
|
|
}
|
|
}
|
|
$newDir
|
|
Write-Host "Maksymalna długość nazwy folderu: $($newDir.split("\")[-1].Length) | Długość ścieżki: $($newDir.Length)"
|
|
Remove-Item $rootDir -Recurse -Force
|
|
|
|
$rootDir = "C:\test_tk_nazwa_pliku"
|
|
$fileName = "file"
|
|
|
|
$counter = 1
|
|
New-Item -Path $rootDir -ItemType Directory -ErrorAction Stop | Out-Null
|
|
while ($true) {
|
|
$newFile = Join-Path -Path $rootDir -ChildPath ($fileName + ("a" * $counter))
|
|
try {
|
|
New-Item -Path $newFile -ItemType File -ErrorAction Stop | Out-Null
|
|
$maxFileLength = $counter
|
|
$counter++
|
|
} catch {
|
|
break
|
|
}
|
|
}
|
|
$newFile
|
|
Write-Host "Maksymalna długość nazwy pliku: $($newFile.split("\")[-1].Length) | Długość ścieżki: $($newFile.Length)"
|
|
Remove-Item $rootDir -Recurse -Force
|
|
|
|
$rootDir = "\\?\C:\test_tk_glebokosc_unc"
|
|
$dirName = "dir"
|
|
|
|
$counter = 1
|
|
$currentDir = $rootDir
|
|
$limit = 300
|
|
|
|
while ($true) {
|
|
$newDir = Join-Path -Path $currentDir -ChildPath ($dirName + $counter)
|
|
try {
|
|
New-Item -Path $newDir -ItemType Directory -ErrorAction Stop | Out-Null
|
|
#Write-Host "Utworzono katalog: $newDir"
|
|
$currentDir = $newDir
|
|
$counter++
|
|
#if ($counter % 100 -eq 0) {
|
|
# "Głębokość $newDir"
|
|
#}
|
|
if ($counter -eq $limit) {
|
|
break
|
|
}
|
|
} catch {
|
|
Write-Host "Nie można utworzyć katalogu: $newDir. Limit filesystemu osiągnięty?"
|
|
break
|
|
}
|
|
}
|
|
|
|
$newDir
|
|
"Utworzono ścieżkę o długości: $($newDir.Length) znaków | Przerwane przy ilości: $($counter) zagnieżdżeń."
|
|
Remove-Item $rootDir -Recurse -Force
|
|
|
|
$rootDir = "\\?\C:\test_tk_nazwa_folderu_unc"
|
|
$dirName = "dir"
|
|
$fileName = "file"
|
|
|
|
$counter = 1
|
|
$maxDirLength = 0
|
|
$maxFileLength = 0
|
|
|
|
while ($true) {
|
|
$newDir = Join-Path -Path $rootDir -ChildPath ($dirName + ("a" * $counter))
|
|
try {
|
|
New-Item -Path $newDir -ItemType Directory -ErrorAction Stop | Out-Null
|
|
$maxDirLength = $counter
|
|
$counter++
|
|
} catch {
|
|
break
|
|
}
|
|
}
|
|
$newDir
|
|
Write-Host "Maksymalna długość nazwy folderu: $($newDir.split("\")[-1].Length) | Długość ścieżki: $($newDir.Length)"
|
|
Remove-Item $rootDir -Recurse -Force
|
|
|
|
$rootDir = "\\?\C:\test_tk_nazwa_pliku_unc"
|
|
$fileName = "file"
|
|
|
|
$counter = 1
|
|
New-Item -Path $rootDir -ItemType Directory -ErrorAction Stop | Out-Null
|
|
while ($true) {
|
|
$newFile = Join-Path -Path $rootDir -ChildPath ($fileName + ("a" * $counter))
|
|
try {
|
|
New-Item -Path $newFile -ItemType File -ErrorAction Stop | Out-Null
|
|
$maxFileLength = $counter
|
|
$counter++
|
|
} catch {
|
|
break
|
|
}
|
|
}
|
|
$newFile
|
|
Write-Host "Maksymalna długość nazwy pliku: $($newFile.split("\")[-1].Length) | Długość ścieżki: $($newFile.Length)"
|
|
Remove-Item $rootDir -Recurse -Force |