ファイル名 | 説明 | 削除コマンド例 |
---|---|---|
CON |
コンソール | Remove-Item -LiteralPath "\\?\$pwd\CON" -Force |
PRN |
プリンター | Remove-Item -LiteralPath "\\?\$pwd\PRN" -Force |
AUX |
補助デバイス | Remove-Item -LiteralPath "\\?\$pwd\AUX" -Force |
NUL |
Nullデバイス | Remove-Item -LiteralPath "\\?\$pwd\NUL" -Force |
COM1 ~COM9 |
シリアルポート | Remove-Item -LiteralPath "\\?\$pwd\COM1" -Force |
LPT1 ~LPT9 |
パラレルポート | Remove-Item -LiteralPath "\\?\$pwd\LPT1" -Force |
ファイル名例 | 問題点 | 削除コマンド例 |
---|---|---|
filename |
末尾スペース | Remove-Item -LiteralPath "\\?\$pwd\filename " -Force |
filename. |
末尾ピリオド | Remove-Item -LiteralPath "\\?\$pwd\filename." -Force |
filename... |
複数の末尾ピリオド | Remove-Item -LiteralPath "\\?\$pwd\filename..." -Force |
file |
複数の末尾スペース | Remove-Item -LiteralPath "\\?\$pwd\file " -Force |
文字 | 説明 | 削除コマンド例(もし存在した場合) |
---|---|---|
< |
小なり記号 | Remove-Item -LiteralPath "\\?\$pwd\file<name" -Force |
> |
大なり記号 | Remove-Item -LiteralPath "\\?\$pwd\file>name" -Force |
: |
コロン(ドライブ文字以外) | Remove-Item -LiteralPath "\\?\$pwd\file:name" -Force |
" |
ダブルクォート | Remove-Item -LiteralPath '\\?\$pwd\file"name' -Force |
| |
パイプ | Remove-Item -LiteralPath "\\?\$pwd\file|name" -Force |
? |
疑問符(ワイルドカード) | Remove-Item -LiteralPath "\\?\$pwd\file?name" -Force |
* |
アスタリスク(ワイルドカード) | Remove-Item -LiteralPath "\\?\$pwd\file*name" -Force |
ケース | 説明 | 削除コマンド例 |
---|---|---|
260文字超のパス | MAX_PATH制限超過 | Remove-Item -LiteralPath "\\?\C:\very\long\path\...\file.txt" -Force |
con.txt |
予約名+拡張子 | Remove-Item -LiteralPath "\\?\$pwd\con.txt" -Force |
nul.log |
予約名+拡張子 | Remove-Item -LiteralPath "\\?\$pwd\nul.log" -Force |
方法 | コマンド | 用途 |
---|---|---|
PowerShell (.NET) | [System.IO.File]::Delete("\\?\$pwd\nul") |
Remove-Itemが失敗した場合 |
コマンドプロンプト | cmd.exe /c del "\\?\%cd%\nul" |
PowerShellから実行 |
絶対パス指定 | Remove-Item -LiteralPath "\\?\C:\full\path\to\nul" -Force |
パスが明確な場合 |
注意:
- 予約デバイス名は大文字小文字を区別しない(NUL = nul = Nul)
\\?\
プレフィックスはWindowsのパス解析をバイパスする- Windows 10/11では長いパスのサポートが改善されているが、レジストリ設定が必要な場合がある