Diskpart assign command using script file not detecting UTF-8 paths

i10v31inux 0 Reputation points
2023-01-31T18:59:46.7333333+00:00

Hi Community,

I am using diskpart command with script file (/s flag) and assigning a VHD file to a temporary directory which contains non-ACII characters, problem here is diskpart reports this directory as invalid however when I assign folder with DiskManagement GUI this works perfectly fine.

Diskpart script contains below commands:

create vdisk file=C:\tp93847435_f7ad_4f7e_b589_9a6e0c8fee0d.vhd maximum=5
select vdisk file=C:\tp93847435_f7ad_4f7e_b589_9a6e0c8fee0d.vhd
attach vdisk
rescan
convert mbr
create partition primary
format fs=ntfs label="install" quick 
assign mount="C:\Users\someuser\AppData\Local\Temp\UP_€_d99S\tp14de94c0_147d_4fe9_96e3_405f604bb26d" 


Everything except last line works fine. Also, I've verified that if assign command used with path containing only ASCII characters, then script executes without any error.

Would like to know if this is expected?? If not, how we can solve this issue or any command line alternative available?

NOTE: I am saving script file in UTF-8 format

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
10,611 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Philippe Levesque 5,681 Reputation points MVP
    2023-01-31T20:02:35.0833333+00:00

    Hi

    cmd is not UNICODE's compliant by default, try cmd /K chcp 65001 to launch it to test again your script.


  2. Limitless Technology 43,931 Reputation points
    2023-02-02T09:00:47.8866667+00:00

    Hi. Thank you for your question and reaching out. I’d be more than happy to help you with your query.

    This is likely because diskpart doesn't support non-ASCII characters in the path while using the script with the '/s' flag.

    One solution to this problem is to use a directory name with only ASCII characters. Another option could be to use a different command-line utility that supports non-ASCII characters in the path, such as mountvol.

    Example:

    mountvol X: "C:\Users\someuser\AppData\Local\Temp\UP_€_d99S\tp14de94c0_147d_4fe9_96e3_405f604bb26d"

    If the reply was helpful, please don’t forget to upvote or accept as answer, thank you.

    0 comments No comments