Windows无法挂载非英文挂载点,DiskPart参数错误如何解决?
Fixing DiskPart's "The parameter is incorrect" Error When Assigning a Mount Point with Japanese Characters
I’ve run into this exact issue before—DiskPart gets tripped up by non-ASCII characters and unquoted paths. Let’s break down what’s wrong and how to fix it:
The Root Causes
Your assign mount line has two critical issues triggering the error:
- Missing quotes around the path: DiskPart treats spaces and special characters (like your Japanese kanji) as parameter separators. Without quotes, it thinks you’re passing multiple invalid parameters instead of a single path.
- Encoding mismatch: PowerShell’s default output encoding doesn’t play well with DiskPart when dealing with non-ASCII characters. DiskPart expects Unicode (UTF-16) for paths containing non-English characters.
Corrected Script
Here’s the fixed version that addresses both problems, plus a safety check for the target directory:
# First, create the parent directory (DiskPart CANNOT create this automatically) New-Item -Path "C:\DATABASES\データベースが" -ItemType Directory -Force $dofflinescript = @" select disk 7 attributes disk clear readonly online disk assign mount="C:\DATABASES\データベースが\DATA5" format unit=64K quick "@ # Save the script to a file with Unicode encoding (DiskPart's preferred format) $dofflinescript | Out-File -FilePath ".\diskpart_mount_script.txt" -Encoding Unicode # Run the script with DiskPart diskpart /s ".\diskpart_mount_script.txt"
Why This Works:
- Quoted Mount Path: Wrapping the path in double quotes (
"...") tells DiskPart to treat the entire string as one parameter, even with spaces or non-ASCII characters. - Unicode Encoding: Using
Out-File -Encoding Unicodeensures the Japanese characters are saved in a format DiskPart can parse correctly—no more garbled text or parameter errors. - Pre-Created Directory: DiskPart will fail if the target directory doesn’t exist, so
New-Itemcreates it first (the-Forceflag skips errors if it already exists).
Alternative: Pipe Directly Without a File
If you prefer not to write to a file, you can pipe the script to DiskPart with UTF-16 encoding directly:
New-Item -Path "C:\DATABASES\データベースが" -ItemType Directory -Force $dofflinescript = @" select disk 7 attributes disk clear readonly online disk assign mount="C:\DATABASES\データベースが\DATA5" format unit=64K quick "@ # Encode the script in UTF-16 before piping to DiskPart $unicodeEncoding = [System.Text.Encoding]::Unicode $scriptBytes = $unicodeEncoding.GetBytes($dofflinescript) $unicodeScript = $unicodeEncoding.GetString($scriptBytes) $unicodeScript | diskpart
Quick Pre-Run Checks
- Verify the target disk: Run
Get-Diskin PowerShell to confirm disk 7 is the one you want to modify—accidentally formatting the wrong drive is a nightmare! - Run as Admin: DiskPart requires administrative privileges to modify disks, so make sure you launch PowerShell as an Administrator.
- Check path typos: Double-check the Japanese characters in your path to avoid typos that could cause DiskPart to fail.
内容的提问来源于stack exchange,提问作者Vishnu Kamavaram
相关产品推荐
相关产品推荐

