Werbung: SecurityConsole.de verwaltet Ihre Computer mit Security Essentails aus der Cloud!
30 Tage kostenfrei testen und 20% Rabatt für Ihre Bestellung mit Promocode: WBF2685582
(Promocode gültig bis 31.12.2011)

Group:  English: Windows Server » microsoft.public.windows.server.scripting
Thread: DISKPART select command doesn't have a "noerr" command for scripti

HTVi
TV Discussion Newsgroups

DISKPART select command doesn't have a "noerr" command for scripti
WB 11/25/2008 1:31:02 AM
I'm trying to programmatically delete all partitions from a drive, however
I'm not sure how many partitions the drive has.

I thought the script below would work, but if any of the partitions don't
exist, the script stops execution when trying to select them. This is because
there is not a "noerr" parameter for selecting the partitions.

I don't understand what good the "noerr" parameters are when you have to
select items first, and the select function has no "noerr" parameter so it
fails???:

BTW: I cannot use "clean" (please don't ask why)

select disk 0
select partition 1
delete partition noerr
select partition 2
delete partition noerr
select partition 3
delete partition noerr
select partition 4
delete partition noerr
select partition 0
delete partition noerr
select disk 0
create partition primary size 2000
format FS=FAT LABEL="PARTITION1" QUICK
assign letter d
create partition extended
create partition logical
format FS=NTFS LABEL="PARTITION2" QUICK
assign letter c
Active
Exit

Thanks,
--
Bill Baker
Re: DISKPART select command doesn't have a "noerr" command for scripti
"Pegasus \(MVP\)" <I.can[ at ]fly.com.oz> 11/25/2008 7:29:21 AM

"WB" <WB[ at ]discussions.microsoft.com> wrote in message
news:D3618F52-6C8F-4239-A240-86E2AFDB2571[ at ]microsoft.com...
[Quoted Text]
> I'm trying to programmatically delete all partitions from a drive, however
> I'm not sure how many partitions the drive has.
>
> I thought the script below would work, but if any of the partitions don't
> exist, the script stops execution when trying to select them. This is
> because
> there is not a "noerr" parameter for selecting the partitions.
>
> I don't understand what good the "noerr" parameters are when you have to
> select items first, and the select function has no "noerr" parameter so it
> fails???:
>
> BTW: I cannot use "clean" (please don't ask why)
>
> select disk 0
> select partition 1
> delete partition noerr
> select partition 2
> delete partition noerr
> select partition 3
> delete partition noerr
> select partition 4
> delete partition noerr
> select partition 0
> delete partition noerr
> select disk 0
> create partition primary size 2000
> format FS=FAT LABEL="PARTITION1" QUICK
> assign letter d
> create partition extended
> create partition logical
> format FS=NTFS LABEL="PARTITION2" QUICK
> assign letter c
> Active
> Exit
>
> Thanks,
> --
> Bill Baker

I don't know anything about diskpart.exe but you could walk around the
problem by using this batch file to automate the job.

[ at ]echo off
echo> diskpart1.scr select disk 0
echo>>diskpart1.scr list partition
echo>>diskpart1.scr exit
diskpart < diskpart1.scr | findstr /i "primary logical" > diskpart.txt

echo>diskpart2.scr select disk 0 > diskpart2.scr
for /F "tokens=1,2" %%a in (diskpart.txt) do (
echo>>diskpart2.scr %%a %%b
echo>>diskpart2.scr delete partition noerr
)

echo>>diskpart2.scr select disk 0
echo>>diskpart2.scr create partition primary size 2000
echo>>diskpart2.scr format FS=FAT LABEL="PARTITION1" QUICK
echo>>diskpart2.scr assign letter d
echo>>diskpart2.scr create partition extended
echo>>diskpart2.scr create partition logical
echo>>diskpart2.scr format FS=NTFS LABEL="PARTITION2" QUICK
echo>>diskpart2.scr assign letter c
echo>>diskpart2.scr Active
echo>>diskpart2.scr Exit

diskpart < diskpart2.scr


Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net
Suche nach Orten, Städten, Postleitzahlen, Vorwahlen, Kfz-Kennzeichen