Diskpart scrip failure

Tiwari, Nitendra 1 Reputation point
2021-06-30T13:16:31.603+00:00

Hi All,

I am running the following script for Format Volume, the script works most of the Time but some time I am getting error as

Script===============================

echo LIST VOLUME > abc.tpm
FOR /F "tokens=1,2,3,4" %%i IN ('diskpart /s abc.tpm') DO if /i '%%i' EQU 'Volume' (
call :FORMATVOLUME %%j %%k %%l
)
goto :EOF

:FORMATVOLUME
%TraceLine% FORMAT VOLUME %1 %2 %3

echo SELECT VOLUME %1 > %DiskPartScript%
echo CLEAN>> %DiskPartScript%

diskpart /s %DiskPartScript% >> %LOG% 2>&1
IF %ERRORLEVEL% EQU 0 (
%TraceLine% OK
goto finished
) else (
%TraceLine% ** Failed to FORMAT VOLUME %1 %2 %3
)
goto :EOF

Trace/Error====================

FORMAT VOLUME 0 NTFS Static

Microsoft DiskPart version 10.0.17763.1

Copyright (C) Microsoft Corporation.
On computer: MININT-KQIPQ6C

Volume 0 is the selected volume.

DiskPart succeeded in cleaning the disk.
OK

FORMAT VOLUME 2 FAT32 SYSTEM

Microsoft DiskPart version 10.0.17763.1

Copyright (C) Microsoft Corporation.
On computer: MININT-KQIPQ6C

The volume you selected is not valid or does not exist.

There is no volume selected.
** Failed to FORMAT VOLUME 2 FAT32 SYSTEM

Please Help to fix this, Error occurred on Gen 4 PCs
Error Occurs in WinPe
OS : Windows 10

Windows for business Windows Client for IT Pros User experience Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2021-07-01T06:48:50.737+00:00

    Hi @Tiwari, Nitendra ,

    Thanks for posting here.

    So sorry that I am not professional with script issue and disk part issue. According to our description, the script works most of the time, and only sometimes we got the error. I guess the script should be working fine.

    Hope someone else could share their knowledge or experience here. Hopefully, our issue could be resolved soon as well.

    Appreciate your understanding and support.

    Best regards,
    Hannah Xiong

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.