andre.nitschke
Goto Top

Automatische Installation von Windows soll Platte löschen

Hallo,
ich möchte gern ein Windows unbeaufsichtigt installieren lassen. Dazu habe ich die entsprechende ISO Datei vorbereitet, und mit sysprep die Datei install.wim vorher erstellt.
Wenn ich von dem Stick in einer Testumgebung (VM VirtualBox) boote läuft es auch tadellos durch. Auf einem echten Gerät bleibt er aber hängen weil er die Festplatte nicht löschen kann. Verbaut ist eine nvme Platte, und diese wird mit diskpart auch erkannt. Die Partitionierung wird mir angezeigt.
Aber beim durchlauf der autounattend.xml löscht er die Partitionen nicht.

Ich vermute das Problem in dem Bereich um diskpart clean in der Datei.

Hier ist meine Autounattend.xml:

<unattend xmlns="urn:schemas-microsoft-com:unattend" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State">  
<!-- https://schneegans.de/windows/unattend-generator/?LanguageMode=Unattended&UILanguage=de-DE&UserLocale=de-DE&KeyboardLayout=0407%3A00000407&ProcessorArchitecture=amd64&ComputerName=&TimeZoneMode=Explicit&TimeZone=W.+Europe+Standard+Time&PartitionMode=Unattended&PartitionLayout=GPT&RecoveryMode=Partition&WindowsEditionMode=Unattended&WindowsEdition=pro&UserAccountMode=Interactive&LockoutMode=Default&WifiMode=Skip&ExpressSettings=DisableAll&WdacMode=Skip -->
<settings pass="offlineServicing"/>  
<settings pass="windowsPE">  
<component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">  
<SetupUILanguage>
<UILanguage>de-DE</UILanguage>
</SetupUILanguage>
<InputLocale>0407:00000407</InputLocale>
<SystemLocale>de-DE</SystemLocale>
<UILanguage>de-DE</UILanguage>
<UserLocale>de-DE</UserLocale>
</component>
<component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">  
<ImageInstall>
<OSImage>
<InstallTo>
<DiskID>0</DiskID>
<PartitionID>3</PartitionID>
</InstallTo>
</OSImage>
</ImageInstall>
<UserData>
<ProductKey>
<Key>xxxx-xxxx-xxxx-xxxx</Key>
</ProductKey>
<AcceptEula>true</AcceptEula>
</UserData>
<RunSynchronous>
<RunSynchronousCommand wcm:action="add">  
<Order>1</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo SELECT DISK=0"</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>2</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo CLEAN"</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>3</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo CONVERT GPT"</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>4</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo CREATE PARTITION EFI SIZE=100"</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>5</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo FORMAT QUICK FS=FAT32 LABEL="System""</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>6</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo CREATE PARTITION MSR SIZE=16"</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>7</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo CREATE PARTITION PRIMARY"</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>8</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo SHRINK MINIMUM=1000"</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>9</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo FORMAT QUICK FS=NTFS LABEL="Windows""</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>10</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo CREATE PARTITION PRIMARY"</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>11</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo FORMAT QUICK FS=NTFS LABEL="Recovery""</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>12</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo SET ID="de94bba4-06d1-4d40-a16a-bfd50179d6ac""</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>13</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo GPT ATTRIBUTES=0x8000000000000001"</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>14</Order>
<Path>cmd.exe /c diskpart /s X:\diskpart.txt >> X:\diskpart.log</Path>
</RunSynchronousCommand>
</RunSynchronous>
</component>
</settings>
<settings pass="generalize"/>  
<settings pass="specialize">  
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">  
<TimeZone>W. Europe Standard Time</TimeZone>
</component>
</settings>
<settings pass="auditSystem"/>  
<settings pass="auditUser"/>  
<settings pass="oobeSystem">  
<component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">  
<InputLocale>0407:00000407</InputLocale>
<SystemLocale>de-DE</SystemLocale>
<UILanguage>de-DE</UILanguage>
<UserLocale>de-DE</UserLocale>
</component>
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">  
<OOBE>
<ProtectYourPC>3</ProtectYourPC>
<HideEULAPage>true</HideEULAPage>
<HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
</OOBE>
</component>
</settings>
</unattend>

Content-Key: 33326788520

Url: https://administrator.de/contentid/33326788520

Printed on: May 6, 2024 at 11:05 o'clock

Member: em-pie
em-pie Dec 11, 2023 at 07:25:47 (UTC)
Goto Top
Moin,

Zwei Dinge:
Dass das bei dir fehlschlägt liegt vermutlich daran, dass du mit jedem Diskpart-Befehl eine neue cmd.exe Instanz öffnest.

Du kannst Partitionen auch direkt in der XML löschen und neu anlegen lassen:
https://learn.microsoft.com/de-de/windows-hardware/customize/desktop/una ...
Das wäre die saubere Variante
Member: andre.nitschke
andre.nitschke Dec 11, 2023 at 08:03:40 (UTC)
Goto Top
WillWipeDisk hatte ich auch mal eingebaut aber es hat nicht geklappt, es kam der Hinweis das in der Datei ein nicht erkannter Befehl ist und die Installation hat abgebrochen.
Wir würde denn eine korrekte autounattend.xml mit diesem Befehl aussehen? Könnte mir jemand meine anpassen?
Member: andre.nitschke
andre.nitschke Dec 11, 2023 at 08:42:14 (UTC)
Goto Top
So ich habe das nach dem Link einmal umgestellt.
Die Fehlermeldung:

Es konnte keine aktive Partition auf dem Datenträger "0" festgelegt werden. Der Zieldatenträger, die Zielpartition oder das Zielvolume unterstützt den angegebenen Vorgang nicht. Der Fehler ist beim Anwenden der Einstellung <DiskKonfiguation> der Antwortdatei für die unbeaufsichtigte Installation aufgetreten. Fehlercode 0x803000024


Die Datei autounattend.xml sieht so aus aktuell:
<unattend xmlns="urn:schemas-microsoft-com:unattend" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State">
<!-- https://schneegans.de/windows/unattend-generator/?LanguageMode=Unattende ... -->
<settings pass="offlineServicing"/>
<settings pass="windowsPE">
<component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
<SetupUILanguage>
<UILanguage>de-DE</UILanguage>
</SetupUILanguage>
<InputLocale>0407:00000407</InputLocale>
<SystemLocale>de-DE</SystemLocale>
<UILanguage>de-DE</UILanguage>
<UserLocale>de-DE</UserLocale>
</component>
<component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
<DiskConfiguration>

<Disk wcm:action="add">
<DiskID>0</DiskID>
<WillWipeDisk>true</WillWipeDisk>
<CreatePartitions>

<!-- System partition -->
<CreatePartition wcm:action="add">
<Order>1</Order>
<Type>Primary</Type>
<Size>300</Size>
</CreatePartition>

<!-- Windows partition -->
<CreatePartition wcm:action="add">
<Order>2</Order>
<Type>Primary</Type>
<Extend>true</Extend>
</CreatePartition>

</CreatePartitions>
<ModifyPartitions>

<!-- System partition -->
<ModifyPartition wcm:action="add">
<Order>1</Order>
<PartitionID>1</PartitionID>
<Label>System</Label>
<Format>NTFS</Format>
<Active>true</Active>
</ModifyPartition>

<!-- Windows partition -->
<ModifyPartition wcm:action="add">
<Order>2</Order>
<PartitionID>2</PartitionID>
<Label>Windows</Label>
<Letter>C</Letter>
<Format>NTFS</Format>
</ModifyPartition>
</ModifyPartitions>
</Disk>

<WillShowUI>OnError</WillShowUI>
</DiskConfiguration>


<ImageInstall>
<OSImage>
<InstallTo>
<DiskID>0</DiskID>
<PartitionID>2</PartitionID>
</InstallTo>
</OSImage>
</ImageInstall>
<UserData>
<ProductKey>
<Key>xxxx-xxxx-xxxx-xxxx</Key>
</ProductKey>
<AcceptEula>true</AcceptEula>
</UserData>

</component>
</settings>
<settings pass="generalize"/>
<settings pass="specialize">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
<TimeZone>W. Europe Standard Time</TimeZone>
</component>
</settings>
<settings pass="auditSystem"/>
<settings pass="auditUser"/>
<settings pass="oobeSystem">
<component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
<InputLocale>0407:00000407</InputLocale>
<SystemLocale>de-DE</SystemLocale>
<UILanguage>de-DE</UILanguage>
<UserLocale>de-DE</UserLocale>
</component>
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
<OOBE>
<ProtectYourPC>3</ProtectYourPC>
<HideEULAPage>true</HideEULAPage>
<HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
</OOBE>
</component>
</settings>
</unattend>
Mitglied: 8030021182
8030021182 Dec 11, 2023 updated at 08:55:00 (UTC)
Goto Top
Bei GPT brauchst du eine EFI-System Partition, und die muss als EFI im Typ gekennzeichnet sein, ohne die kein Boot ...
Und die MSR solltest du auch anlegen, ist zwar kein Muss aber MS will das best Practice so für zukünftige Erweiterungen.

UEFI/GPT-based hard drive partitions

1000002698

Gruß Katrin
Member: cschneegans
cschneegans Dec 12, 2023 at 14:38:27 (UTC)
Goto Top
<Path>cmd.exe /c diskpart /s X:\diskpart.txt >> X:\diskpart.log</Path>

schreibt Fehlermeldungen nach X:\diskpart.log. Wenn die Fehlermeldung erscheint, also Umschalt+F10 drücken und

type X:\diskpart.log

tippen.

Wenn sowohl das diskpart-Skript als auch <DiskConfiguration> scheitern, erscheint mir die Vermutung naheliegend, dass dein NVME-Gerät von Windows PE nicht erkannt wird.

Zitat von @em-pie:

Dass das bei dir fehlschlägt liegt vermutlich daran, dass du mit jedem Diskpart-Befehl eine neue cmd.exe Instanz öffnest.

Es gibt in dieser autounattend.xml genau einen diskpart-Befehl.

Du kannst Partitionen auch direkt in der XML löschen und neu anlegen lassen:
https://learn.microsoft.com/de-de/windows-hardware/customize/desktop/una ...

Per diskpart-Skript lässt sich die Partitionierung, die von Microsoft empfohlen und vom Windows Setup bei einer beaufsichtigten Installation vorgenommen wird, erheblich eleganter und kompakter erzeugen als mit <DiskConfiguration>.
Member: andre.nitschke
andre.nitschke Dec 14, 2023 at 08:52:41 (UTC)
Goto Top
So ich bin jetzt einen Schritt weiter.
Die Lösung mit diskpart scheint zu klappen. Und das Problem ist folgendes:
Manche Computer haben eine Festplatte verbaut, und manche haben 2 Festplatten.
Für jede Situation brauch ich einen eigenen USB-Stick weil die autounattend.xml sich
unterscheidet. Bei 2 Platten muss ich für beine ein Clean machen, bei einer Platte nur für diese.
Aber wenn ich den Stick für 2 Platten (wo in der autounattend.xml beide Platten gelöscht werden) in den Rechner mit einer Platte stecke kommt es zum Fehler und das Setup bricht ab.

Meine Frage: Kann man das so zusammenfassen das ich mit einer autounattend.xml beide Szenarien abdecke? Das er beide Platten löscht (also Disk ID 0 und Disk ID 1) wenn vorhanden, sonst nur die erste?

Hier mal beide Dateien die ich erstellt habe, und die in ihrem Szenario auch funktionieren:


Für ein Laufwerk:
<RunSynchronous>
<RunSynchronousCommand wcm:action="add">  
<Order>1</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo SELECT DISK=0"</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>2</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo CLEAN"</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>3</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo CONVERT GPT"</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>4</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo CREATE PARTITION EFI SIZE=100"</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>5</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo FORMAT QUICK FS=FAT32 LABEL="System""</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>6</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo CREATE PARTITION MSR SIZE=16"</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>7</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo CREATE PARTITION PRIMARY"</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>8</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo SHRINK MINIMUM=1000"</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>9</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo FORMAT QUICK FS=NTFS LABEL="Windows""</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>10</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo CREATE PARTITION PRIMARY"</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>11</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo FORMAT QUICK FS=NTFS LABEL="Recovery""</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>12</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo SET ID="de94bba4-06d1-4d40-a16a-bfd50179d6ac""</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>13</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo GPT ATTRIBUTES=0x8000000000000001"</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>14</Order>
<Path>cmd.exe /c diskpart /s X:\diskpart.txt >> X:\diskpart.log</Path>
</RunSynchronousCommand>
</RunSynchronous>

Für 2 Laufwerke:

<RunSynchronousCommand wcm:action="add">  
<Order>1</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo SELECT DISK=1"</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>2</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo CLEAN"</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>3</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo SELECT DISK=0"</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>4</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo CLEAN"</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>5</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo CONVERT GPT"</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>6</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo CREATE PARTITION EFI SIZE=100"</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>7</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo FORMAT QUICK FS=FAT32 LABEL="System""</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>8</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo CREATE PARTITION MSR SIZE=16"</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>9</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo CREATE PARTITION PRIMARY"</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>10</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo SHRINK MINIMUM=1000"</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>11</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo FORMAT QUICK FS=NTFS LABEL="Windows""</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>12</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo CREATE PARTITION PRIMARY"</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>13</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo FORMAT QUICK FS=NTFS LABEL="Recovery""</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>14</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo SET ID="de94bba4-06d1-4d40-a16a-bfd50179d6ac""</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>15</Order>
<Path>cmd.exe /c ">>"X:\diskpart.txt" echo GPT ATTRIBUTES=0x8000000000000001"</Path>  
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">  
<Order>16</Order>
<Path>cmd.exe /c diskpart /s X:\diskpart.txt >> X:\diskpart.log</Path>
</RunSynchronousCommand>
Member: cschneegans
cschneegans Dec 14, 2023 at 13:46:23 (UTC)
Goto Top
Zitat von @andre.nitschke:

Bei 2 Platten muss ich für beine ein Clean machen, bei einer Platte nur für diese.
Aber wenn ich den Stick für 2 Platten (wo in der autounattend.xml beide Platten gelöscht werden) in den Rechner mit einer Platte stecke kommt es zum Fehler und das Setup bricht ab.

diskpart zweimal aufrufen und beim zweiten Aufruf den Fehler ignorieren:

<Path>cmd.exe /c "&gt;&gt;"X:\diskpart0.txt" echo SELECT DISK=0"</Path>  
<Path>cmd.exe /c "&gt;&gt;"X:\diskpart0.txt" echo CLEAN"</Path>  
<Path>...</Path>
<Path>cmd.exe /c "&gt;&gt;"X:\diskpart0.log" diskpart.exe /s "X:\diskpart0.txt""</Path>  

<Path>cmd.exe /c "&gt;&gt;"X:\diskpart1.txt" echo SELECT DISK=1"</Path>  
<Path>cmd.exe /c "&gt;&gt;"X:\diskpart1.txt" echo CLEAN"</Path>  
<Path>cmd.exe /c "&gt;&gt;"X:\diskpart1.log" diskpart.exe /s "X:\diskpart1.txt" &amp; exit 0"</Path>