@uffbros The Windows version has no connection with the partitioning. The script creates partitions and just copies whatever Windows ISO version you select onto the usb disk. The FAT32 boot partition gets hidden that's probably why you only see one partition
Ok so that is a change then from the previous version I was using where it showed both? I think I had ver 1.92. Thanks
@freddie-o Instead of creating 2 partitions, we could format the usb disk as fat32 and split the install.wim if greater than 4 GB. What's your opinion?
You mean like this https://forums.mydigitallife.net/th...-install-esd-install-swm-creation-tool.78925/
No, I mean a new fork of this thread, or add an option to the gui to choose between the present implementation, or splitting install.wim.
What i have in mind as a fork of this script is something like a "windows 11 setup disk" implementing this https://forums.mydigitallife.net/threads/windows-11-boot-device-creation-with-ufws.84489/ Either a separate script or if doable add the option in Win10 setup disk script for installing windows 11
Quick and dirty : Spoiler Code: <# : standard way of doing hybrid batch + powershell scripts @title Win10 Setup Disk 2.4 &color f0 @set "__ARGS__=%*" &powershell -noprofile "$ScriptPath='%~f0';iex((Get-Content('%~f0') -Raw))" &exit/b #> # # Homepage: https://forums.mydigitallife.net/threads/win10-setup-disk-works-with-uefi-with-secure-boot-bios-install-wim-over-4-gb.79268/ # Credits: @rpo, @freddie-o, @BAU & @abbodi1406 # # This script must be executed with admin privilege # # Test Administrator privileges If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { $uac_error="Elevating UAC for Administrator Privileges failed" # The following test is to avoid infinite looping if elevating UAC for Administrator Privileges failed if ($env:__ARGS__ -eq $uac_error) { read-host "$uac_error`r`nRight click on the script and select ""Run as administrator""`r`nPress Enter to exit...";exit} # Restart the script to get Administrator privileges and exit Start-Process "$ScriptPath" $uac_error -Verb runAs; exit } $pswindow = $host.ui.rawui # create a reference to the console’s UI.RawUI child object $pswindow.windowtitle = ([string]($pswindow.windowtitle -split "^.* ")).trim() ; $ShortTitle=($pswindow.windowtitle -split " @ .*")[0] # Add-Type -AssemblyName System.Windows.Forms # Load the class System.Windows.Forms # Filebrowser dialog object $FileBrowser = New-Object System.Windows.Forms.OpenFileDialog -Property @{ Multiselect = $false # One file can be chosen Filter = 'ISO images (*.iso)|*.iso' # Select only iso files } # Add-Type -Name Window -Namespace Console -MemberDefinition ' [DllImport("Kernel32.dll")] public static extern IntPtr GetConsoleWindow(); [DllImport("user32.dll")] public static extern bool ShowWindow(IntPtr hWnd, Int32 nCmdShow); ' function Show-Console {[Console.Window]::ShowWindow([Console.Window]::GetConsoleWindow(), 1)|Out-Null}# Show console function Hide-Console {[Console.Window]::ShowWindow([Console.Window]::GetConsoleWindow(), 0)|Out-Null}# Hide console # # Function MsgBox {[System.Windows.Forms.MessageBox]::Show($Args[0],$ShortTitle,$Args[1],$Args[2])} # Hide-Console clear-host $swmsize=4000 $USB=$Null $Form=New-Object System.Windows.Forms.Form # Create the screen form (window) $Form.TopMost = $True # Set the title and size of the window: $Form.Text=$ShortTitle $Form.Font='Consolas,10' $Form.Width=420 ; $Form.Height=265 $Form.StartPosition = "CenterScreen" $Form.SizeGripStyle = "Hide" [System.Windows.Forms.Application]::EnableVisualStyles(); # Create a drop-down list and fill it $USBDiskList=New-Object System.Windows.Forms.ComboBox $USBDiskList.DropDownStyle=[System.Windows.Forms.ComboBoxStyle]::DropDownList; $USBDiskList.Location=New-Object System.Drawing.Point(20,40) $USBDiskList.Size=New-Object System.Drawing.Size(363,22) $Form.Controls.Add($SelectUSBDiskList) $USBDisks=@() # array with USB disk number # $Disks=$Null;While (!$Disks){ If(!($Disks=Get-Disk | Where-Object {($_.BusType -eq "USB") -and ($_.OperationalStatus -eq "Online")})){ if((MsgBox "Please plug in your USB disk first. `n`nClick OK to continue." "OKCancel" "Information") -eq "Cancel") {exit}}} $USBDisk=New-Object System.Windows.Forms.Label # Put the USB Disk label on the form $USBDisk.Location=New-Object System.Drawing.Point(20,20) $USBDisk.Text="USB Disk" $USBDisk.Size=New-Object System.Drawing.Size(200,20) $Form.Controls.Add($USBDisk) $ISOImage=New-Object System.Windows.Forms.Label # Put the ISO Image label on the form $ISOImage.Location=New-Object System.Drawing.Point(20,85) $ISOImage.Size=New-Object System.Drawing.Size(200,20) $ISOImage.text="ISO Image" $Form.Controls.Add($ISOImage) $ISOFile=New-Object System.Windows.Forms.Label # Put the ISO file name on the form $ISOFile.Location=New-Object System.Drawing.Point(20,105) $ISOFile.Text=" " $ISOFile.Size=New-Object System.Drawing.Size(364,24) $ISOFile.Backcolor = [System.Drawing.Color]::White $ISOFile.BorderStyle = [System.Windows.Forms.BorderStyle]::FixedSingle $Form.Controls.Add($ISOFile) # $checkBox40 = New-Object System.Windows.Forms.CheckBox $checkBox40.Location = New-Object System.Drawing.Point(20,145) $checkBox40.Name = "checkBox40" $checkBox40.Size = New-Object System.Drawing.Size(364,24) $checkBox40.Checked=$True $checkBox40.Text = "Split install.wim if > $swmsize GB" $form.Controls.Add($checkBox40) # $CancelButton=New-Object System.Windows.Forms.Button # Put the Cancel button on the form $CancelButton.Location=New-Object System.Drawing.Point(285,180) $CancelButton.Text="Cancel" $CancelButton.Size=New-Object System.Drawing.Size(100,26) $Form.Controls.Add($CancelButton) $CancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel $SelectISOButton=New-Object System.Windows.Forms.Button # Put the Select ISO button on the form $SelectISOButton.Location=New-Object System.Drawing.Point(150,180) $SelectISOButton.Text="Select ISO" $SelectISOButton.Size=New-Object System.Drawing.Size(100,26) $Form.Controls.Add($SelectISOButton) $CreateDiskButton=New-Object System.Windows.Forms.Button # Put the Create Disk button on the form $CreateDiskButton.Location=New-Object System.Drawing.Point(20,180) $CreateDiskButton.Text="Create Disk" $CreateDiskButton.Size=New-Object System.Drawing.Size(100,26) $Form.Controls.Add($CreateDiskButton) $CreateDiskButton.Enabled = $false $CreateDiskButton.DialogResult = [System.Windows.Forms.DialogResult]::OK $SelectISOButton.Add_Click({ If ($FileBrowser.ShowDialog() -ne "Cancel"){ # if Cancel, just ignore $Global:ImagePath = $FileBrowser.filename # return the file name $ISOFile.Text= Split-Path -Path $ImagePath -leaf # extract filename and extension (iso) if (($ISOFile.Text).length -gt 44) {$ISOFile.Text = $ImagePath.PadRight(100," ").substring(0,43)+"..."} $CreateDiskButton.Enabled = $true $CreateDiskButton.Focus()}}) Foreach ($USBDisk in $Disks) { $FriendlyName=($USBDisk.FriendlyName).PadRight(40," ").substring(0,39) $USBDisks+=$USBDisk.DiskNumber $USBDiskList.Items.Add(("{0,-39}{1:n2} GB" -f $FriendlyName,($USBDisk.Size/1GB)))|out-null $Partitions = Get-Partition | Where-Object { $_.DiskNumber -eq $USBDisk.DiskNumber} If ($Partitions) { Foreach ($Partition in $Partitions) { If(!$Partition.DriveLetter){$AccessPath=" "} Else {$AccessPath=$Partition.DriveLetter+":"} $Volumes=get-volume | Where-Object {$Partition.AccessPaths -contains $_.path } Foreach ($Volume in $Volumes) { $USBDisks+=$USBDisk.DiskNumber $USBDiskList.Items.Add(("{0,0}({1,2}){2,-32}[{3:n2} GB]" -f " ", ($AccessPath), $Volume.FileSystemLabel.PadRight(25," ").substring(0,25), ($Partition.Size/1GB)))|out-null } } } } $form.Controls.Add($USBDiskList) $USBDiskList.SelectedIndex=0 # $Groupbox=New-Object System.Windows.Forms.Groupbox # Add a group box on the form $Groupbox.Location=New-Object System.Drawing.Point(7,0) $Groupbox.Text="" $Groupbox.Size=New-Object System.Drawing.Size(390,220) $Form.Controls.Add($Groupbox) # if($form.ShowDialog() -eq "Cancel") {MsgBox "The script was cancelled." "OK" "Information"|out-Null;exit} # Show-Console # restablish console view for the no gui part of the script $form.ShowInTaskbar = $False $form.Hide()$form.ShowInTaskbar = $False $form.Hide() # At this point the mounted USB disk and the iso image file path are defined # $USB=$USBDisks[$USBDiskList.SelectedIndex] # If ($checkBox40.Checked){$splitwim=1}Else{$splitwim=0} # If((MsgBox "WARNING! `n`nYour USB disk will be converted to MBR scheme, repartitioned and reformatted.`n`nAll partitions and data currently stored in the USB disk will be erased.`r`n`r`nAre you sure you want to continue?" "YESNO" "Warning") -eq "NO"){exit} # Mount the image file if not already mounted and get the drive letter # # Check if iso already mounted by getting driveletter If($ISO=(Get-DiskImage -ImagePath $ImagePath | Get-Volume).DriveLetter){$Mounted=$True} Else # Mount iso and get drive letter {$Mounted=$False; Mount-DiskImage -ImagePath $ImagePath -StorageType ISO |out-null If(!($ISO=(Get-DiskImage -ImagePath $ImagePath | Get-Volume).DriveLetter)){Exit}} $ISO=$ISO+":" # set bootmenupolicy Legacy Copy-Item $ISO"\boot\bcd" $env:temp\bcdmbr -Force & bcdedit /store ($env:temp + "\bcdmbr") /set '{default}' bootmenupolicy Legacy Set-ItemProperty -Path ($env:temp + "\bcdmbr") -Name IsReadOnly -Value $true Copy-Item $ISO"\EFI\Microsoft\boot\bcd" $env:temp\bcdefi -Force & bcdedit /store ($env:temp + "\bcdefi") /set '{default}' bootmenupolicy Legacy Set-ItemProperty -Path ($env:temp + "\bcdefi") -Name IsReadOnly -Value $true # Clear-Host if (Test-Path "$iso\sources\install.wim"){$WimFile="install.wim"} if (Test-Path "$iso\sources\install.esd"){$WimFile="install.esd"} $NTFS=1 If((Get-Item "$iso\Sources\$WimFile").Length/1MB -lt $swmsize){ $NTFS=0} else{ If ((Test-Path "$iso\sources\install.wim") -and ($Splitwim -gt 0)){$NTFS=0} } # Clear the USB disk "Select disk $USB`r`nclean`r`nconvert MBR`r`nrescan`r`nexit" |diskpart # Stop-Service ShellHWDetection -erroraction silentlycontinue|out-null # Create the fat32 boot partition IF ($NTFS -gt 0){ $usbfat32=(New-Partition -DiskNumber $usb -Size 1GB -AssignDriveLetter | Format-Volume -FileSystem FAT32 -NewFileSystemLabel "BOOT").DriveLetter + ":" # Create the NTFS intall partition $usbntfs=(New-Partition -DiskNumber $usb -UseMaximumSize -AssignDriveLetter -IsActive | Format-Volume -FileSystem NTFS -NewFileSystemLabel "SETUP").DriveLetter + ":"} else { $usbfat32=(New-Partition -DiskNumber $usb -UseMaximumSize -AssignDriveLetter -IsActive| Format-Volume -FileSystem FAT32 -NewFileSystemLabel "SETUP").DriveLetter + ":"} Start-Service ShellHWDetection -erroraction silentlycontinue|out-null # IF ($NTFS -gt 0){ # Copy needed files to the fat32 boot partition robocopy $iso"\" $usbfat32"\" bootmgr bootmgr.efi robocopy $iso"\boot" $usbfat32"\boot" /e /xf $iso\boot\bcd robocopy $iso"\efi" $usbfat32"\efi" /e /xf $iso\efi\microsoft\boot\bcd robocopy $iso"\sources" $usbfat32"\sources" boot.wim Copy-Item ($env:temp + "\bcdmbr") $usbfat32"\boot\bcd" -Force Copy-Item ($env:temp + "\bcdefi") $usbfat32"\EFI\Microsoft\boot\bcd" -Force # Remove the drive letter to hide the device Get-Volume -DriveLetter $usbfat32.substring(0,$usbfat32.Length-1) | Get-Partition | Remove-PartitionAccessPath -accesspath $usbfat32 # # # Copy needed files to the NTFS install partition robocopy $iso $usbntfs /e /xf $iso\boot\bcd $iso\efi\microsoft\boot\bcd Copy-Item ($env:temp + "\bcdmbr") $usbntfs"\boot\bcd" -Force Copy-Item ($env:temp + "\bcdefi") $usbntfs"\EFI\Microsoft\boot\bcd" -Force } else{ robocopy $iso $usbfat32 /e /xf $iso\boot\bcd $iso\efi\microsoft\boot\bcd $iso\sources\install.wim Copy-Item ($env:temp + "\bcdmbr") $usbfat32"\boot\bcd" -Force Copy-Item ($env:temp + "\bcdefi") $usbfat32"\EFI\Microsoft\boot\bcd" -Force If((Get-Item "$iso\Sources\install.wim").Length/1MB -lt $swmsize){ robocopy "$iso\sources" "$usbfat32\sources" install.wim} else {Dism /Split-Image /ImageFile:"$iso\sources\install.wim" /SWMFile:"$usbfat32\sources\install.swm" /FileSize:$swmsize} } # # House keeping remove-item ($env:temp + "\bcdmbr") -force remove-item ($env:temp + "\bcdmbr.*") -force remove-item ($env:temp + "\bcdefi") -force remove-item ($env:temp + "\bcdefi.*") -force # # Eject the mounted iso image if it was loaded by the script If(!$Mounted){DisMount-DiskImage -ImagePath $ImagePath |out-null} MsgBox (($ShortTitle -split " @.*")[0]+" was created successfully.") "OK" "Information" |Out-Null;exit Added a check box to split install.wim. If install.win < 4000 : one fat32 partition if install.wim >= 4000 and the check box checked : one fat32 partition and install.wim splitted if install.wim >= 4000 and the check box not checked : one fat32 partition and one ntfs partition the $swmsize variable is given the value 4000, this can be changed.
Update: If the Selected Procedure for creating was a drop down list instead? Code: <# : standard way of doing hybrid batch + powershell scripts @title Win10+ Setup Disk 3.0 @set "__ARGS__=%*" &powershell -noprofile "$ScriptPath='%~f0';iex((Get-Content('%~f0') -Raw))" &exit/b #> # # Homepage: https://forums.mydigitallife.net/threads/win10-setup-disk-works-with-uefi-with-secure-boot-bios-install-wim-over-4-gb.79268/ # Credits: @rpo, @freddie-o, @BAU & @abbodi1406 # # This script must be executed with admin privilege # # Test Administrator privileges If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { $uac_error="Elevating UAC for Administrator Privileges failed" # The following test is to avoid infinite looping if elevating UAC for Administrator Privileges failed if ($env:__ARGS__ -eq $uac_error) { read-host "$uac_error`r`nRight click on the script and select ""Run as administrator""`r`nPress Enter to exit...";exit} # Restart the script to get Administrator privileges and exit Start-Process "$ScriptPath" $uac_error -Verb runAs; exit } $pswindow = $host.ui.rawui # create a reference to the console’s UI.RawUI child object $pswindow.windowtitle = ([string]($pswindow.windowtitle -split "^.* ")).trim() ; $ShortTitle=($pswindow.windowtitle -split " @ .*")[0] # Add-Type -AssemblyName System.Windows.Forms # Load the class System.Windows.Forms # Filebrowser dialog object $FileBrowser = New-Object System.Windows.Forms.OpenFileDialog -Property @{ Multiselect = $false # One file can be chosen Filter = 'ISO images (*.iso)|*.iso' # Select only iso files } # Add-Type -Name Window -Namespace Console -MemberDefinition ' [DllImport("Kernel32.dll")] public static extern IntPtr GetConsoleWindow(); [DllImport("user32.dll")] public static extern bool ShowWindow(IntPtr hWnd, Int32 nCmdShow); ' function Show-Console {[Console.Window]::ShowWindow([Console.Window]::GetConsoleWindow(), 1)|Out-Null}# Show console function Hide-Console {[Console.Window]::ShowWindow([Console.Window]::GetConsoleWindow(), 0)|Out-Null}# Hide console # Function MsgBox {[System.Windows.Forms.MessageBox]::Show($Args[0],$ShortTitle,$Args[1],$Args[2])} # Hide-Console clear-host $swmsize=4000 $USB=$Null $Form=New-Object System.Windows.Forms.Form # Create the screen form (window) $Form.TopMost = $True # Set the title and size of the window: $Form.Text=$ShortTitle $Form.Font='Consolas,10' $Form.Width=420 ; $Form.Height=315 $Form.StartPosition = "CenterScreen" $Form.SizeGripStyle = "Hide" [System.Windows.Forms.Application]::EnableVisualStyles(); # $USBDisk=New-Object System.Windows.Forms.Label # Put Selected USB Disk label on the form $USBDisk.Location=New-Object System.Drawing.Point(20,20) $USBDisk.Text="Selected USB Disk" $USBDisk.Size=New-Object System.Drawing.Size(200,20) $Form.Controls.Add($USBDisk) # $USBDiskList=New-Object System.Windows.Forms.ComboBox # Create a USB drop-down list and fill it $USBDiskList.DropDownStyle=[System.Windows.Forms.ComboBoxStyle]::DropDownList; $USBDiskList.Location=New-Object System.Drawing.Point(20,40) $USBDiskList.Size=New-Object System.Drawing.Size(363,22) $Form.Controls.Add($SelectUSBDiskList) $USBDisks=@() # array with USB disk number # $Disks=$Null;While (!$Disks){ If(!($Disks=Get-Disk | Where-Object {($_.BusType -eq "USB") -and ($_.OperationalStatus -eq "Online")})){ if((MsgBox "Plug in your USB disk first. `n`nClick OK to continue." "OKCancel" "Information") -eq "Cancel") {exit}}} # $SelectProcedure=New-Object System.Windows.Forms.Label # Put Selected Procedure for creating Setup disk on the form $SelectProcedure.Location=New-Object System.Drawing.Point(20,85) $SelectProcedure.Size=New-Object System.Drawing.Size(350,20) $SelectProcedure.text="Selected Procedure If Install Wim is Over 4GB" $Form.Controls.Add($SelectProcedure) # $ProcedureList=New-Object System.Windows.Forms.ComboBox # Create a procedure drop-down list and fill it $ProcedureList.DropDownStyle=[System.Windows.Forms.ComboBoxStyle]::DropDownList; $ProcedureList.Location=New-Object System.Drawing.Point(20,105) $ProcedureList.Size=New-Object System.Drawing.Size(363,22) $Form.Controls.Add($ProcedureList) # $ISOImage=New-Object System.Windows.Forms.Label # Put the ISO Image label on the form $ISOImage.Location=New-Object System.Drawing.Point(20,150) $ISOImage.Size=New-Object System.Drawing.Size(200,20) $ISOImage.text="Selected ISO Image" $Form.Controls.Add($ISOImage) # $ISOFile=New-Object System.Windows.Forms.Label # Put the ISO file name on the form $ISOFile.Location=New-Object System.Drawing.Point(20,170) $ISOFile.Text=" " $ISOFile.Size=New-Object System.Drawing.Size(364,24) $ISOFile.Backcolor = [System.Drawing.Color]::White $ISOFile.BorderStyle = [System.Windows.Forms.BorderStyle]::FixedSingle $Form.Controls.Add($ISOFile) # $CancelButton=New-Object System.Windows.Forms.Button # Put the Cancel button on the form $CancelButton.Location=New-Object System.Drawing.Point(270,230) $CancelButton.Text="Cancel" $CancelButton.Size=New-Object System.Drawing.Size(115,26) $Form.Controls.Add($CancelButton) $CancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel # $SelectISOButton=New-Object System.Windows.Forms.Button # Put the Select ISO button on the form $SelectISOButton.Location=New-Object System.Drawing.Point(145,230) $SelectISOButton.Text="Select ISO" $SelectISOButton.Size=New-Object System.Drawing.Size(115,26) $Form.Controls.Add($SelectISOButton) # $CreateDiskButton=New-Object System.Windows.Forms.Button # Put the Create Disk button on the form $CreateDiskButton.Location=New-Object System.Drawing.Point(20,230) $CreateDiskButton.Text="Create Disk" $CreateDiskButton.Size=New-Object System.Drawing.Size(115,26) $Form.Controls.Add($CreateDiskButton) $CreateDiskButton.Enabled = $false $CreateDiskButton.DialogResult = [System.Windows.Forms.DialogResult]::OK # $SelectISOButton.Add_Click({ If ($FileBrowser.ShowDialog() -ne "Cancel"){ # if Cancel, just ignore $Global:ImagePath = $FileBrowser.filename # return the file name $ISOFile.Text= Split-Path -Path $ImagePath -leaf # extract filename and extension (iso) if (($ISOFile.Text).length -gt 44) {$ISOFile.Text = $ImagePath.PadRight(100," ").substring(0,43)+"..."} $CreateDiskButton.Enabled = $true $CreateDiskButton.Focus()}}) # Foreach ($USBDisk in $Disks) { $FriendlyName=($USBDisk.FriendlyName).PadRight(40," ").substring(0,39) $USBDisks+=$USBDisk.DiskNumber $USBDiskList.Items.Add(("{0,-39}{1:n2} GB" -f $FriendlyName,($USBDisk.Size/1GB)))|out-null $Partitions = Get-Partition | Where-Object { $_.DiskNumber -eq $USBDisk.DiskNumber} If ($Partitions) { Foreach ($Partition in $Partitions) { If(!$Partition.DriveLetter){$AccessPath=" "} Else {$AccessPath=$Partition.DriveLetter+":"} $Volumes=get-volume | Where-Object {$Partition.AccessPaths -contains $_.path } Foreach ($Volume in $Volumes) { $USBDisks+=$USBDisk.DiskNumber $USBDiskList.Items.Add(("{0,0}({1,2}){2,-32}[{3:n2} GB]" -f " ", ($AccessPath), $Volume.FileSystemLabel.PadRight(25," ").substring(0,25), ($Partition.Size/1GB)))|out-null } } } } $form.Controls.Add($USBDiskList) $USBDiskList.SelectedIndex=0 # $Groupbox=New-Object System.Windows.Forms.Groupbox # Add a group box on the form $Groupbox.Location=New-Object System.Drawing.Point(7,0) $Groupbox.Text="" $Groupbox.Size=New-Object System.Drawing.Size(390,270) $Form.Controls.Add($Groupbox) # if($form.ShowDialog() -eq "Cancel") {MsgBox "The script was cancelled." "OK" "Information"|out-Null;exit} # # At this point the mounted USB disk and the iso image file path are defined # $USB=$USBDisks[$USBDiskList.SelectedIndex] # If ($checkBox40.Checked){$splitwim=1}Else{$splitwim=0} # If((MsgBox "WARNING! `n`nYour USB disk will be converted to MBR scheme, repartitioned and reformatted.`n`nAll partitions and data currently stored in the USB disk will be erased.`r`n`r`nAre you sure you want to continue?" "YESNO" "Warning") -eq "NO"){exit} # Mount the image file if not already mounted and get the drive letter # Show-Console # restablish console view for the no gui part of the script $form.ShowInTaskbar = $False $form.Hide() # # Check if iso already mounted by getting driveletter If($ISO=(Get-DiskImage -ImagePath $ImagePath | Get-Volume).DriveLetter){$Mounted=$True} Else # Mount iso and get drive letter {$Mounted=$False; Mount-DiskImage -ImagePath $ImagePath -StorageType ISO |out-null If(!($ISO=(Get-DiskImage -ImagePath $ImagePath | Get-Volume).DriveLetter)){Exit}} $ISO=$ISO+":" # set bootmenupolicy Legacy Copy-Item $ISO"\boot\bcd" $env:temp\bcdmbr -Force & bcdedit /store ($env:temp + "\bcdmbr") /set '{default}' bootmenupolicy Legacy Set-ItemProperty -Path ($env:temp + "\bcdmbr") -Name IsReadOnly -Value $true Copy-Item $ISO"\EFI\Microsoft\boot\bcd" $env:temp\bcdefi -Force & bcdedit /store ($env:temp + "\bcdefi") /set '{default}' bootmenupolicy Legacy Set-ItemProperty -Path ($env:temp + "\bcdefi") -Name IsReadOnly -Value $true # Clear-Host if (Test-Path "$iso\sources\install.wim"){$WimFile="install.wim"} if (Test-Path "$iso\sources\install.esd"){$WimFile="install.esd"} $NTFS=1 If((Get-Item "$iso\Sources\$WimFile").Length/1MB -lt $swmsize){ $NTFS=0} else{ If ((Test-Path "$iso\sources\install.wim") -and ($Splitwim -gt 0)){$NTFS=0} } # Clear the USB disk "Select disk $USB`r`nclean`r`nconvert MBR`r`nrescan`r`nexit" |diskpart # Stop-Service ShellHWDetection -erroraction silentlycontinue|out-null # Create the fat32 boot partition IF ($NTFS -gt 0){ $usbfat32=(New-Partition -DiskNumber $usb -Size 1GB -AssignDriveLetter | Format-Volume -FileSystem FAT32 -NewFileSystemLabel "BOOT").DriveLetter + ":" # Create the NTFS intall partition $usbntfs=(New-Partition -DiskNumber $usb -UseMaximumSize -AssignDriveLetter -IsActive | Format-Volume -FileSystem NTFS -NewFileSystemLabel "SETUP").DriveLetter + ":"} else { $usbfat32=(New-Partition -DiskNumber $usb -UseMaximumSize -AssignDriveLetter -IsActive| Format-Volume -FileSystem FAT32 -NewFileSystemLabel "SETUP").DriveLetter + ":"} Start-Service ShellHWDetection -erroraction silentlycontinue|out-null # IF ($NTFS -gt 0){ # Copy needed files to the fat32 boot partition robocopy $iso"\" $usbfat32"\" bootmgr bootmgr.efi robocopy $iso"\boot" $usbfat32"\boot" /e /xf $iso\boot\bcd robocopy $iso"\efi" $usbfat32"\efi" /e /xf $iso\efi\microsoft\boot\bcd robocopy $iso"\sources" $usbfat32"\sources" boot.wim Copy-Item ($env:temp + "\bcdmbr") $usbfat32"\boot\bcd" -Force Copy-Item ($env:temp + "\bcdefi") $usbfat32"\EFI\Microsoft\boot\bcd" -Force # Remove the drive letter to hide the device Get-Volume -DriveLetter $usbfat32.substring(0,$usbfat32.Length-1) | Get-Partition | Remove-PartitionAccessPath -accesspath $usbfat32 # # Copy needed files to the NTFS install partition robocopy $iso $usbntfs /e /xf $iso\boot\bcd $iso\efi\microsoft\boot\bcd Copy-Item ($env:temp + "\bcdmbr") $usbntfs"\boot\bcd" -Force Copy-Item ($env:temp + "\bcdefi") $usbntfs"\EFI\Microsoft\boot\bcd" -Force } else{ robocopy $iso $usbfat32 /e /xf $iso\boot\bcd $iso\efi\microsoft\boot\bcd $iso\sources\install.wim Copy-Item ($env:temp + "\bcdmbr") $usbfat32"\boot\bcd" -Force Copy-Item ($env:temp + "\bcdefi") $usbfat32"\EFI\Microsoft\boot\bcd" -Force If((Get-Item "$iso\Sources\install.wim").Length/1MB -lt $swmsize){ robocopy "$iso\sources" "$usbfat32\sources" install.wim} else {Dism /Split-Image /ImageFile:"$iso\sources\install.wim" /SWMFile:"$usbfat32\sources\install.swm" /FileSize:$swmsize} } # # House keeping remove-item ($env:temp + "\bcdmbr") -force remove-item ($env:temp + "\bcdmbr.*") -force remove-item ($env:temp + "\bcdefi") -force remove-item ($env:temp + "\bcdefi.*") -force # # Eject the mounted iso image if it was loaded by the script If(!$Mounted){DisMount-DiskImage -ImagePath $ImagePath |out-null} MsgBox (($ShortTitle -split " @.*")[0]+" was created successfully.") "OK" "Information" |Out-Null;exit
It took me a while to figure out what the 3 was in your script. Seems more fitting Win10+ Setup Disk 3.0
New version here : https://drive.google.com/file/d/1ETaL7bGRKi2LuradmCOFhwfziB8q5_L8/view?usp=sharing
I cannot figure out which modifications I made is causing the script to create a FAT32 and NTFS partition when I select "Split the Install.wim" Code: <# : standard way of doing hybrid batch + powershell scripts @title Win10+ Setup Disk 3.0 &color 3E @set "__ARGS__=%*" &powershell -noprofile "$ScriptPath='%~f0';iex((Get-Content('%~f0') -Raw))" &exit/b #> # # Homepage: https://forums.mydigitallife.net/threads/win10-setup-disk-works-with-uefi-with-secure-boot-bios-install-wim-over-4-gb.79268/ # Credits: @rpo, @freddie-o, @BAU & @abbodi1406 # # This script must be executed with admin privilege # # Test Administrator privileges If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { $uac_error="Elevating UAC for Administrator Privileges failed" # The following test is to avoid infinite looping if elevating UAC for Administrator Privileges failed if ($env:__ARGS__ -eq $uac_error) { read-host "$uac_error`r`nRight click on the script and select ""Run as administrator""`r`nPress Enter to exit...";exit} # Restart the script to get Administrator privileges and exit Start-Process "$ScriptPath" $uac_error -Verb runAs; exit } $pswindow = $host.ui.rawui # create a reference to the console’s UI.RawUI child object $pswindow.windowtitle = ([string]($pswindow.windowtitle -split "^.* ")).trim() ; $ShortTitle=($pswindow.windowtitle -split " @ .*")[0] # Add-Type -AssemblyName System.Windows.Forms # Load the class System.Windows.Forms # Filebrowser dialog object $FileBrowser = New-Object System.Windows.Forms.OpenFileDialog -Property @{ Multiselect = $false # One file can be chosen Filter = 'ISO images (*.iso)|*.iso' # Select only iso files } # Function MsgBox {[System.Windows.Forms.MessageBox]::Show($Args[0],$ShortTitle,$Args[1],$Args[2])} # Function Update_bcd { param ($iso, $usbpartition) "Set bootmenupolicy Legacy for $usbpartition" Copy-Item "$iso\boot\bcd" "$usbpartition\boot\bcd" -Force Copy-Item "$iso\EFI\Microsoft\boot\bcd" "$usbpartition\EFI\Microsoft\boot\bcd" -Force & bcdedit /store "$usbpartition\boot\bcd" /set '{default}' bootmenupolicy Legacy |Out-Null & bcdedit /store "$usbpartition\EFI\Microsoft\boot\bcd" /set '{default}' bootmenupolicy Legacy |Out-Null Set-ItemProperty -Path "$usbpartition\boot\bcd" -Name IsReadOnly -Value $true Set-ItemProperty -Path "$usbpartition\EFI\Microsoft\boot\bcd" -Name IsReadOnly -Value $true remove-item "$usbpartition\boot\bcd.*" -force remove-item "$usbpartition\EFI\Microsoft\boot\bcd.*" -force } # clear-host $swmsize=4000 $USB=$Null $Form=New-Object System.Windows.Forms.Form # Create the screen form (window) $Form.TopMost = $True # Set the title and size of the window: $Form.Text=$ShortTitle $Form.Font='Consolas,9' $Form.Width=420 ; $Form.Height=315 $Form.StartPosition = "CenterScreen" $Form.SizeGripStyle = "Hide" [System.Windows.Forms.Application]::EnableVisualStyles(); # $USBDisk=New-Object System.Windows.Forms.Label # Put Selected USB Disk label on the form $USBDisk.Location=New-Object System.Drawing.Point(20,20) $USBDisk.Text="Selected USB Disk" $USBDisk.Size=New-Object System.Drawing.Size(200,20) $Form.Controls.Add($USBDisk) # $USBDiskList=New-Object System.Windows.Forms.ComboBox # Create a drop-down list and fill it $USBDiskList.DropDownStyle=[System.Windows.Forms.ComboBoxStyle]::DropDownList; $USBDiskList.Location=New-Object System.Drawing.Point(20,40) $USBDiskList.Size=New-Object System.Drawing.Size(363,22) $Form.Controls.Add($SelectUSBDiskList) $USBDisks=@() # array with USB disk number # $Disks=$Null;While (!$Disks){ If(!($Disks=Get-Disk | Where-Object {($_.BusType -eq "USB") -and ($_.OperationalStatus -eq "Online")})){ if((MsgBox "Plug in your USB disk first. `n`nClick OK to continue." "OKCancel" "Information") -eq "Cancel") {exit}}} # $SelectProcedure=New-Object System.Windows.Forms.Label # Put Selected Procedure for creating Setup disk on the form $SelectProcedure.Location=New-Object System.Drawing.Point(20,85) $SelectProcedure.Size=New-Object System.Drawing.Size(380,20) $SelectProcedure.text="Selected Procedure if Install Wim is more than 4GB" $Form.Controls.Add($SelectProcedure) # $ProcedureList=New-Object System.Windows.Forms.ComboBox # Create a procedure drop-down list and fill it $ProcedureList.DropDownStyle=[System.Windows.Forms.ComboBoxStyle]::DropDownList; $ProcedureList.Location=New-Object System.Drawing.Point(20,105) $ProcedureList.Size=New-Object System.Drawing.Size(363,22) [void] $ProcedureList.Items.Add("Split the Install.wim") [void] $ProcedureList.Items.Add("Create a FAT32 and NTFS partition") [void] $ProcedureList.Items.Add("Install.wim is less than 4GB") $Form.Controls.Add($ProcedureList) # $ProcedureList.SelectedIndex=0 # $ISOImage=New-Object System.Windows.Forms.Label # Put the ISO Image label on the form $ISOImage.Location=New-Object System.Drawing.Point(20,150) $ISOImage.Size=New-Object System.Drawing.Size(200,20) $ISOImage.text="Selected ISO Image" $Form.Controls.Add($ISOImage) # $ISOFile=New-Object System.Windows.Forms.Label # Put the ISO file name on the form $ISOFile.Location=New-Object System.Drawing.Point(20,170) $ISOFile.Text=" " $ISOFile.Size=New-Object System.Drawing.Size(364,24) $ISOFile.Backcolor = [System.Drawing.Color]::White $ISOFile.BorderStyle = [System.Windows.Forms.BorderStyle]::FixedSingle $Form.Controls.Add($ISOFile) # $CancelButton=New-Object System.Windows.Forms.Button # Put the Cancel button on the form $CancelButton.Location=New-Object System.Drawing.Point(270,230) $CancelButton.Text="Cancel" $CancelButton.Size=New-Object System.Drawing.Size(115,26) $Form.Controls.Add($CancelButton) $CancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel # $SelectISOButton=New-Object System.Windows.Forms.Button # Put the Select ISO button on the form $SelectISOButton.Location=New-Object System.Drawing.Point(145,230) $SelectISOButton.Text="Select ISO" $SelectISOButton.Size=New-Object System.Drawing.Size(115,26) $Form.Controls.Add($SelectISOButton) # $CreateDiskButton=New-Object System.Windows.Forms.Button # Put the Create Disk button on the form $CreateDiskButton.Location=New-Object System.Drawing.Point(20,230) $CreateDiskButton.Text="Create Disk" $CreateDiskButton.Size=New-Object System.Drawing.Size(115,26) $Form.Controls.Add($CreateDiskButton) $CreateDiskButton.Enabled = $false $CreateDiskButton.DialogResult = [System.Windows.Forms.DialogResult]::OK # $SelectISOButton.Add_Click({ If ($FileBrowser.ShowDialog() -ne "Cancel"){ # if Cancel, just ignore $Global:ImagePath = $FileBrowser.filename # return the file name $ISOFile.Text= Split-Path -Path $ImagePath -leaf # extract filename and extension (iso) if (($ISOFile.Text).length -gt 44) {$ISOFile.Text = $ImagePath.PadRight(100," ").substring(0,49)+"..."} $CreateDiskButton.Enabled = $true $CreateDiskButton.Focus()}}) # Foreach ($USBDisk in $Disks) { $FriendlyName=($USBDisk.FriendlyName).PadRight(40," ").substring(0,39) $USBDisks+=$USBDisk.DiskNumber $USBDiskList.Items.Add(("{0,-39}{1:n2} GB" -f $FriendlyName,($USBDisk.Size/1GB)))|out-null $Partitions = Get-Partition | Where-Object { $_.DiskNumber -eq $USBDisk.DiskNumber} If ($Partitions) { Foreach ($Partition in $Partitions) { If(!$Partition.DriveLetter){$AccessPath=" "} Else {$AccessPath=$Partition.DriveLetter+":"} $Volumes=get-volume | Where-Object {$Partition.AccessPaths -contains $_.path } Foreach ($Volume in $Volumes) { $USBDisks+=$USBDisk.DiskNumber $USBDiskList.Items.Add(("{0,0}({1,2}){2,-32}[{3:n2} GB]" -f " ", ($AccessPath), $Volume.FileSystemLabel.PadRight(25," ").substring(0,25), ($Partition.Size/1GB)))|out-null } } } } $form.Controls.Add($USBDiskList) $USBDiskList.SelectedIndex=0 # $Groupbox=New-Object System.Windows.Forms.Groupbox # Add a group box on the form $Groupbox.Location=New-Object System.Drawing.Point(7,0) $Groupbox.Text="" $Groupbox.Size=New-Object System.Drawing.Size(390,270) $Form.Controls.Add($Groupbox) # echo "Select your USB Disk, the procedure (how you want your Setup disk created) and your ISO image." echo "Your $ShortTitle will start as soon as you click the 'Create Disk' button." # if($form.ShowDialog() -eq "Cancel") {MsgBox "The script was cancelled." "OK" "Information"|out-Null;exit} # # At this point the mounted USB disk and the iso image file path are defined # $USB=$USBDisks[$USBDiskList.SelectedIndex] # If ($ProcedureList.SelectedIndex -eq 0){$splitwim=1}Else{$splitwim=0} # If((MsgBox "WARNING! `n`nYour USB disk will be converted to MBR scheme, repartitioned and reformatted.`n`nAll partitions and data currently stored in the USB disk will be erased.`r`n`r`nAre you sure you want to continue?" "YESNO" "Warning") -eq "NO"){exit} # Mount the image file if not already mounted and get the drive letter # # Check if iso already mounted by getting driveletter If($ISO=(Get-DiskImage -ImagePath $ImagePath | Get-Volume).DriveLetter){$Mounted=$True} Else # Mount iso and get drive letter {$Mounted=$False; Mount-DiskImage -ImagePath $ImagePath -StorageType ISO |out-null If(!($ISO=(Get-DiskImage -ImagePath $ImagePath | Get-Volume).DriveLetter)){Exit}} $ISO=$ISO+":" Clear-Host if (Test-Path "$iso\sources\install.wim"){$WimFile="install.wim"} if (Test-Path "$iso\sources\install.esd"){$WimFile="install.esd"} $NTFS=1 If((Get-Item "$iso\Sources\$WimFile").Length/1MB -lt $swmsize){ $NTFS=0} else{ If ((Test-Path "$iso\sources\install.wim") -and ($Splitwim -gt 0)){$NTFS=0} } # Clear the USB stick Clear-Disk $usb -RemoveData -RemoveOEM -Confirm:$false set-disk $usb -partitionstyle mbr Stop-Service ShellHWDetection -erroraction silentlycontinue|out-null ##################################################################### # Create partition(s) # IF ($NTFS -gt 0){ $usbfat32=(New-Partition -DiskNumber $usb -Size 1GB -AssignDriveLetter | Format-Volume -FileSystem FAT32 -NewFileSystemLabel "BOOT").DriveLetter + ":" # Create the NTFS intall partition $usbntfs=(New-Partition -DiskNumber $usb -UseMaximumSize -AssignDriveLetter -IsActive | Format-Volume -FileSystem NTFS -NewFileSystemLabel "SETUP").DriveLetter + ":"} else { $usbfat32=(New-Partition -DiskNumber $usb -UseMaximumSize -AssignDriveLetter -IsActive| Format-Volume -FileSystem FAT32 -NewFileSystemLabel "SETUP").DriveLetter + ":"} Start-Service ShellHWDetection -erroraction silentlycontinue|out-null ##################################################################### IF ($NTFS -gt 0){ # # One fat32 partition and one ntfs partition # # Copy needed files to the fat32 boot partition robocopy $iso"\" $usbfat32"\" bootmgr bootmgr.efi robocopy $iso"\boot" $usbfat32"\boot" /e /xf $iso\boot\bcd robocopy $iso"\efi" $usbfat32"\efi" /e /xf $iso\efi\microsoft\boot\bcd Update_BCD $iso $usbfat32 robocopy $iso"\sources" $usbfat32"\sources" boot.wim # Remove the drive letter to hide the device Get-Volume -DriveLetter $usbfat32.substring(0,$usbfat32.Length-1) | Get-Partition | Remove-PartitionAccessPath -accesspath $usbfat32 # # # Copy needed files to the NTFS install partition robocopy $iso $usbntfs /e /xf $iso\boot\bcd $iso\efi\microsoft\boot\bcd Update_BCD $iso $usbntfs } ##################################################################### else{ # # One fat32 partition # robocopy $iso $usbfat32 /e /xf $iso\boot\bcd $iso\efi\microsoft\boot\bcd $iso\sources\install.wim Update_BCD $iso $usbfat32 If((Get-Item "$iso\Sources\install.wim").Length/1MB -lt $swmsize){ robocopy "$iso\sources" "$usbfat32\sources" install.wim} else {Dism /Split-Image /ImageFile:"$iso\sources\install.wim" /SWMFile:"$usbfat32\sources\install.swm" /FileSize:$swmsize} } ##################################################################### # # Eject the mounted iso image if it was loaded by the script If(!$Mounted){DisMount-DiskImage -ImagePath $ImagePath |out-null} MsgBox (($ShortTitle -split " @.*")[0]+" was created successfully.") "OK" "Information" |Out-Null;exit
Two possibilities : - delete line 88 or -replace line 174 Code: If ($ProcedureList.SelectedIndex -eq 1){$splitwim=1}Else{$splitwim=0}
When choosing the "Split the Install.wim" procedure I get 2 errors After setting bootmenupolicy Legacy the script stops and the "MsgBox ...was created successfully" does not appear Spoiler Errors (2x) in splitting the install.wim -- 1 Install.swm (1.38 GB) Spoiler Update: I am wondering if splitting the Install.wim is worth it when we already got around that by creating a FAT32 and NTFS partition. It keeps on having errors. Even Akeo (Rufus) is against it because it takes a lot of time and possibly cause errors which users are not going to be happy about
Under construction It's more or less finished here : https://drive.google.com/file/d/1RmY6_x-5kff3iiijzL9lQ4ifZMT0XBTm/view?usp=sharing