You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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:

  1. 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.
  2. Unicode Encoding: Using Out-File -Encoding Unicode ensures the Japanese characters are saved in a format DiskPart can parse correctly—no more garbled text or parameter errors.
  3. Pre-Created Directory: DiskPart will fail if the target directory doesn’t exist, so New-Item creates it first (the -Force flag 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-Disk in 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 09:01:11