|
| 1 | +$ErrorActionPreference = 'Stop' |
| 2 | +if ($makeversion -eq "w1164") { |
| 3 | + # make 11 23h2 64 |
| 4 | + $ospath = "/系统/MSDN/NT10.0_Win11/22631_23H2/2428_RTM/zh-cn_windows_11_business_editions_version_23h2_x64_dvd_2a79e0f1.iso" |
| 5 | + $WUScript = "https://raw.githubusercontent.com/adavak/Win_ISO_Patching_Scripts/master/Scripts/script_22621_x64.meta4" |
| 6 | + $Miracast = "https://file.uhsea.com/2404/9dee091435ee149c1f6207f70fb46a6a7U.cab" |
| 7 | + $MiracastLP = "https://file.uhsea.com/2404/9f8486cf6b5fe60d7f0fff1777715b8cW0.cab" |
| 8 | + $iexplorer = "https://file.uhsea.com/2404/0d0a81d87b97263a9745229c715b849bKF.cab" |
| 9 | + $msstore = $true |
| 10 | + $SelectEdition = "Professional" |
| 11 | +} if ($makeversion -eq "w1164uup") { |
| 12 | + # make 11 23h2 64 (updates from uupdump) |
| 13 | + $ospath = "/系统/MSDN/NT10.0_Win11/22631_23H2/2428_RTM/zh-cn_windows_11_business_editions_version_23h2_x64_dvd_2a79e0f1.iso" |
| 14 | + $uupid = ((Invoke-WebRequest -Uri "https://uupdump.net/known.php?q=category:w11-23h2").Links.href | Where-Object {$_ -like "selectlang.php?id=*"})[0].replace("selectlang.php?id=","") |
| 15 | + $UUPScript = "https://uupdump.net/get.php?id=$uupid&pack=0&edition=updateOnly&aria2=2" |
| 16 | + $Miracast = "https://file.uhsea.com/2404/9dee091435ee149c1f6207f70fb46a6a7U.cab" |
| 17 | + $MiracastLP = "https://file.uhsea.com/2404/9f8486cf6b5fe60d7f0fff1777715b8cW0.cab" |
| 18 | + $iexplorer = "https://file.uhsea.com/2404/0d0a81d87b97263a9745229c715b849bKF.cab" |
| 19 | + $msstore = $true |
| 20 | + $SelectEdition = "Professional" |
| 21 | +} elseif ($makeversion -eq "w1064") { |
| 22 | + # make 10 22h2 64 |
| 23 | + $ospath = "/系统/MSDN/NT10.0_Win10/19045_22H2/2006_RTM/zh-cn_windows_10_business_editions_version_22h2_x64_dvd_037e269d.iso" |
| 24 | + $WUScript = "https://raw.githubusercontent.com/adavak/Win_ISO_Patching_Scripts/master/Scripts/script_19041_x64.meta4" |
| 25 | + $NETScript = "https://raw.githubusercontent.com/adavak/Win_ISO_Patching_Scripts/master/Scripts/netfx4.8.1/script_netfx4.8.1_19041_x64.meta4" |
| 26 | + $Miracast = "https://file.uhsea.com/2404/fa949c449de5880ea5e0648e16aa802a43.cab" |
| 27 | + $MiracastLP = "https://file.uhsea.com/2404/907cdd078f41d9b8ca0615b5c1557790S1.cab" |
| 28 | + $msstore = $true |
| 29 | + $SelectEdition = "Professional" |
| 30 | +} elseif ($makeversion -eq "w1064uup") { |
| 31 | + # make 10 22h2 64 (updates from uupdump) |
| 32 | + $ospath = "/系统/MSDN/NT10.0_Win10/19045_22H2/2006_RTM/zh-cn_windows_10_business_editions_version_22h2_x64_dvd_037e269d.iso" |
| 33 | + $uupid = ((Invoke-WebRequest -Uri "https://uupdump.net/known.php?q=category:w10-22h2").Links | Where-Object {$_.href -like "selectlang.php?id=*"} | Where-Object {$_.outerHTML -like "*amd64*"})[0].href.replace("selectlang.php?id=","") |
| 34 | + $UUPScript = "https://uupdump.net/get.php?id=$uupid&pack=0&edition=updateOnly&aria2=2" |
| 35 | + $NETScript = "https://raw.githubusercontent.com/adavak/Win_ISO_Patching_Scripts/master/Scripts/netfx4.8.1/script_netfx4.8.1_19041_x64.meta4" |
| 36 | + $Miracast = "https://file.uhsea.com/2404/fa949c449de5880ea5e0648e16aa802a43.cab" |
| 37 | + $MiracastLP = "https://file.uhsea.com/2404/907cdd078f41d9b8ca0615b5c1557790S1.cab" |
| 38 | + $msstore = $true |
| 39 | + $SelectEdition = "Professional" |
| 40 | +} elseif ($makeversion -eq "w10lt2164") { |
| 41 | + # make 10 ltsc2021 64 |
| 42 | + $ospath = "/系统/MSDN/NT10.0_Win10/19044_LTSC2021/zh-cn_windows_10_enterprise_ltsc_2021_x64_dvd_033b7312.iso" |
| 43 | + $WUScript = "https://raw.githubusercontent.com/adavak/Win_ISO_Patching_Scripts/master/Scripts/script_19041_x64.meta4" |
| 44 | + $NETScript = "https://raw.githubusercontent.com/adavak/Win_ISO_Patching_Scripts/master/Scripts/netfx4.8.1/script_netfx4.8.1_19041_x64.meta4" |
| 45 | +} elseif ($makeversion -eq "w10lt1964") { |
| 46 | + # make 10 ltsc2019 64 |
| 47 | + $ospath = "/系统/MSDN/NT10.0_Win10/17763_LTSC2019/cn_windows_10_enterprise_ltsc_2019_x64_dvd_9c09ff24.iso" |
| 48 | + $WUScript = "https://raw.githubusercontent.com/adavak/Win_ISO_Patching_Scripts/master/Scripts/script_17763_x64.meta4" |
| 49 | + $NETScript = "https://raw.githubusercontent.com/adavak/Win_ISO_Patching_Scripts/master/Scripts/netfx4.8/script_netfx4.8_17763_x64.meta4" |
| 50 | +} elseif ($makeversion -eq "w10lt1664") { |
| 51 | + # make 10 ltsb2016 64 |
| 52 | + $ospath = "/系统/MSDN/NT10.0_Win10/14393_LTSB2016/cn_windows_10_enterprise_2016_ltsb_x64_dvd_9060409.iso" |
| 53 | + $WUScript = "https://raw.githubusercontent.com/adavak/Win_ISO_Patching_Scripts/master/Scripts/script_14393_x64.meta4" |
| 54 | + $NETScript = "https://raw.githubusercontent.com/adavak/Win_ISO_Patching_Scripts/master/Scripts/netfx4.8/script_netfx4.8_14393_x64.meta4" |
| 55 | +} else { |
| 56 | + Write-Error "Not defined or Unsupported OS version" |
| 57 | +} |
| 58 | + |
| 59 | +# remove temporaty files |
| 60 | +Remove-Item -Path ".\temp\" -Recurse -ErrorAction Ignore |
| 61 | +New-Item -Path ".\temp\" -ItemType "directory" -ErrorAction Ignore |
| 62 | + |
| 63 | +# Installing dependencies |
| 64 | +if (-not (Test-Path -Path ".\bin\rclone.conf")) { |
| 65 | + Write-Error "rclone conf not found" |
| 66 | +} |
| 67 | +if (-not (Test-Path -Path ".\bin\rclone.exe")) { |
| 68 | + Write-Host "rclone not found, downloading..." |
| 69 | + Invoke-WebRequest -Uri 'https://downloads.rclone.org/rclone-current-windows-amd64.zip' -outfile .\temp\rclone.zip |
| 70 | + Expand-Archive -Path .\temp\rclone.zip -DestinationPath .\temp\ -Force |
| 71 | + Copy-Item -Path .\temp\rclone-*-windows-amd64\rclone.exe -Destination .\bin\rclone.exe |
| 72 | +} |
| 73 | +if (-not (Test-Path -Path ".\bin\aria2c.exe")) { |
| 74 | + Write-Host "aria2c not found, downloading..." |
| 75 | + Invoke-WebRequest -Uri 'https://github.com/aria2/aria2/releases/download/release-1.37.0/aria2-1.37.0-win-64bit-build1.zip' -outfile .\temp\aria2.zip |
| 76 | + Expand-Archive -Path .\temp\aria2.zip -DestinationPath .\temp -Force |
| 77 | + Move-Item -Path .\temp\aria2-1.37.0-win-64bit-build1\aria2c.exe -Destination .\bin\aria2c.exe -Force |
| 78 | +} |
| 79 | +if (-not (Test-Path -Path ".\bin\wimlib-imagex.exe")) { |
| 80 | + Write-Host "wimlib-imagex not found, downloading..." |
| 81 | + Invoke-WebRequest -Uri 'https://wimlib.net/downloads/wimlib-1.14.4-windows-x86_64-bin.zip' -outfile .\temp\wimlib.zip |
| 82 | + Expand-Archive -Path .\temp\wimlib.zip -DestinationPath .\temp\wimlib -Force |
| 83 | + Copy-Item -Path .\temp\wimlib\wimlib-imagex.exe -Destination .\bin\wimlib-imagex.exe |
| 84 | + Copy-Item -Path .\temp\wimlib\libwim-15.dll -Destination .\bin\libwim-15.dll |
| 85 | +} |
| 86 | +if (-not (Test-Path -Path ".\bin\PSFExtractor.exe")) { |
| 87 | + Write-Host "wimlib-imagex not found, downloading..." |
| 88 | + Invoke-WebRequest -Uri 'https://github.com/Secant1006/PSFExtractor/releases/download/v3.07/PSFExtractor-v3.07-x64.zip' -outfile .\temp\PSFExtractor.zip |
| 89 | + Expand-Archive -Path .\temp\PSFExtractor.zip -DestinationPath .\bin -Force |
| 90 | +} |
| 91 | + |
| 92 | +# get wupatch |
| 93 | +if ($null -ne $UUPScript) { |
| 94 | + Invoke-WebRequest -Uri $UUPScript -OutFile ".\UUPScript.txt" |
| 95 | + .\bin\aria2c.exe --check-certificate=false -x16 -s16 -j5 -c -R -d ".\patch" -i ".\UUPScript.txt" |
| 96 | + if (!$?) {Write-Error "UUPScript Download Failed!"} |
| 97 | +} elseif ($null -ne $WUScript) { |
| 98 | + Invoke-WebRequest -Uri $WUScript -OutFile ".\WUScript.meta4" |
| 99 | + .\bin\aria2c.exe --check-certificate=false -x16 -s16 -j5 -c -R -d ".\patch" -M ".\WUScript.meta4" |
| 100 | + if (!$?) {Write-Error "WUScript Download Failed!"} |
| 101 | +} else { |
| 102 | + Write-Error "No Windows Update Scripts Found!" |
| 103 | +} |
| 104 | +if ($null -ne $NETScript) { |
| 105 | + Invoke-WebRequest -Uri $NETScript -OutFile ".\NETScript.meta4" |
| 106 | + .\bin\aria2c.exe --check-certificate=false -x16 -s16 -j5 -c -R -d ".\patch" -M ".\NETScript.meta4" --metalink-language="neutral" |
| 107 | + if (!$?) {Write-Error "NETScript Download Failed!"} |
| 108 | + .\bin\aria2c.exe --check-certificate=false -x16 -s16 -j5 -c -R -d ".\patch" -M ".\NETScript.meta4" --metalink-language="zh-CN" |
| 109 | + if (!$?) {Write-Error "NETScript Download Failed!"} |
| 110 | +} |
| 111 | + |
| 112 | +# get fod |
| 113 | +if ($null -ne $Miracast) { |
| 114 | + # Microsoft-Windows-WirelessDisplay-FOD-Package~31bf3856ad364e35~amd64~~.cab |
| 115 | + .\bin\aria2c.exe --check-certificate=false -x16 -s16 -d ".\fod\Miracast\" -o "update.cab" "$Miracast" |
| 116 | + if (!$?) {Write-Error "Miracast Download Failed!"} |
| 117 | + expand -f:* ".\fod\Miracast\update.cab" ".\fod\Miracast\" |
| 118 | + # Microsoft-Windows-WirelessDisplay-FOD-Package~31bf3856ad364e35~amd64~zh-CN~.cab |
| 119 | + .\bin\aria2c.exe --check-certificate=false -x16 -s16 -d ".\fod\MiracastLP\" -o "update.cab" "$MiracastLP" |
| 120 | + if (!$?) {Write-Error "MiracastLP Download Failed!"} |
| 121 | + expand -f:* ".\fod\Miracast\update.cab" ".\fod\MiracastLP\" |
| 122 | +} |
| 123 | +if ($null -ne $iexplorer) { |
| 124 | + # microsoft-windows-internetexplorer-optional-package~31bf3856ad364e35~amd64~~.cab |
| 125 | + .\bin\aria2c.exe --check-certificate=false -x16 -s16 -d ".\fod\iexplorer\" -o "update.cab" "$iexplorer" |
| 126 | + if (!$?) {Write-Error "iexplorer Download Failed!"} |
| 127 | + expand -f:* ".\fod\iexplorer\update.cab" ".\fod\iexplorer\" |
| 128 | +} |
| 129 | + |
| 130 | +if ($true -eq $msstore) { |
| 131 | + # get msstore |
| 132 | + .\getappx.ps1 |
| 133 | + $MSStoreScript = " |
| 134 | + for %%a in (%~dp0msstore\Microsoft.UI.Xaml.2.*_8wekyb3d8bbwe.Appx) do call :Add-ProvisionedAppxPackage `"%%a`" |
| 135 | + for %%a in (%~dp0msstore\Microsoft.VCLibs.140.00.UWPDesktop_14.0.*_8wekyb3d8bbwe.Appx) do call :Add-ProvisionedAppxPackage `"%%a`" |
| 136 | + for %%a in (%~dp0msstore\Microsoft.VCLibs.140.00_14.0.*_8wekyb3d8bbwe.Appx) do call :Add-ProvisionedAppxPackage `"%%a`" |
| 137 | + for %%a in (%~dp0msstore\Microsoft.NET.Native.Runtime.2.*_8wekyb3d8bbwe.Appx) do call :Add-ProvisionedAppxPackage `"%%a`" |
| 138 | + for %%a in (%~dp0msstore\Microsoft.NET.Native.Framework.2.*_8wekyb3d8bbwe.Appx) do call :Add-ProvisionedAppxPackage `"%%a`" |
| 139 | + for %%a in (%~dp0msstore\Microsoft.WindowsStore_*_8wekyb3d8bbwe.Msixbundle) do call :Add-ProvisionedAppxPackage `"%%a`" |
| 140 | + for %%a in (%~dp0msstore\Microsoft.DesktopAppInstaller_*_8wekyb3d8bbwe.Msixbundle) do call :Add-ProvisionedAppxPackage `"%%a`" |
| 141 | + " |
| 142 | +} |
| 143 | + |
| 144 | + |
| 145 | +# abbodi1406/W10UI, auto inject hook after resetbase |
| 146 | +(Invoke-WebRequest -Uri "https://raw.githubusercontent.com/abbodi1406/BatUtil/master/W10UI/W10UI.cmd").Content.Replace("if %AddDrivers%==1 call :doDrv","call %~dp0hook.cmd") | Out-File -FilePath ".\W10UI.cmd" |
| 147 | + |
| 148 | +# get osimage |
| 149 | +# get original system direct link |
| 150 | +$obj = (Invoke-WebRequest -UseBasicParsing -Uri "https://alist.xrgzs.top/api/fs/get" ` |
| 151 | +-Method "POST" ` |
| 152 | +-ContentType "application/json;charset=UTF-8" ` |
| 153 | +-Body (@{ |
| 154 | + path = $ospath |
| 155 | + password = "" |
| 156 | +} | Convertto-Json)).Content | ConvertFrom-Json |
| 157 | +$osurl = $obj.data.raw_url |
| 158 | +$osfile = $obj.data.name |
| 159 | +.\bin\aria2c.exe --check-certificate=false -s16 -x16 -d ".\temp" -o "$osfile" "$osurl" |
| 160 | +if ($?) {Write-Host "System Image Download Successfully!"} else {Write-Error "System Image Download Failed!"} |
| 161 | + |
| 162 | +# $isopath = Resolve-Path -Path ".\temp\$osfile" |
| 163 | +# $isomount = (Mount-DiskImage -ImagePath $isopath -PassThru | Get-Volume).DriveLetter |
| 164 | +# Target =${isomount}: |
| 165 | +."C:\Program Files\7-Zip\7z.exe" x ".\temp\$osfile" -o".\ISO" -r |
| 166 | + |
| 167 | +# select 1 edition only |
| 168 | +if ($null -ne $SelectEdition) { |
| 169 | + .\bin\wimlib-imagex.exe info ".\ISO\sources\install.wim" --extract-xml ".\temp\WIMInfo.xml" |
| 170 | + $WIMInfo = [xml](Get-Content ".\temp\WIMInfo.xml") |
| 171 | + $WIMIndex = $WIMInfo.WIM.IMAGE | Where-Object {$_.WINDOWS.EDITIONID -eq "$SelectEdition"} | Select-Object -ExpandProperty INDEX |
| 172 | + $WIMIndexs = $WIMInfo.WIM.IMAGE.Index | Measure-Object | Select-Object -ExpandProperty Count |
| 173 | + for ($i = $WIMIndexs; $i -gt $WIMIndex; $i--) { |
| 174 | + # .\bin\wimlib-imagex.exe delete ".\ISO\sources\install.wim" $i --soft |
| 175 | + Remove-WindowsImage -ImagePath ".\ISO\sources\install.wim" -Index $i |
| 176 | + } |
| 177 | + for ($i = 1; $i -lt $WIMIndex; $i++) { |
| 178 | + Remove-WindowsImage -ImagePath ".\ISO\sources\install.wim" -Index 1 |
| 179 | + } |
| 180 | +} |
| 181 | + |
| 182 | +.\bin\wimlib-imagex.exe info ".\ISO\sources\install.wim" --extract-xml ".\temp\WIMInfo2.xml" |
| 183 | +Get-Content ".\temp\WIMInfo2.xml" |
| 184 | + |
| 185 | +# write W10UI conf |
| 186 | +"[W10UI-Configuration] |
| 187 | +Target =%cd%\ISO |
| 188 | +Repo =%cd%\patch |
| 189 | +DismRoot =dism.exe |
| 190 | +
|
| 191 | +Net35 =1 |
| 192 | +Net35Source = |
| 193 | +Cleanup =1 |
| 194 | +ResetBase =0 |
| 195 | +LCUwinre =1 |
| 196 | +WinRE =1 |
| 197 | +UpdtBootFiles =1 |
| 198 | +SkipEdge =0 |
| 199 | +UseWimlib =1 |
| 200 | +
|
| 201 | +_CabDir =W10UItemp |
| 202 | +MountDir =W10UImount |
| 203 | +WinreMount =W10UImountre |
| 204 | +
|
| 205 | +wim2esd =1 |
| 206 | +wim2swm =0 |
| 207 | +ISO =1 |
| 208 | +ISODir = |
| 209 | +Delete_Source =0 |
| 210 | +
|
| 211 | +AutoStart =1 |
| 212 | +
|
| 213 | +AddDrivers =0 |
| 214 | +Drv_Source =\Drivers |
| 215 | +" | Out-File -FilePath ".\W10UI.ini" |
| 216 | + |
| 217 | +# write hook script |
| 218 | +" |
| 219 | +if exist `"!mountdir!\Windows\Servicing\Packages\*WinPE-LanguagePack*.mum`" exit /b |
| 220 | +
|
| 221 | +echo. |
| 222 | +echo ============================================================ |
| 223 | +echo Enable Features... |
| 224 | +echo ============================================================ |
| 225 | +
|
| 226 | +%_dism2%:`"!_cabdir!`" %dismtarget% /Enable-Feature:LegacyComponents /All |
| 227 | +%_dism2%:`"!_cabdir!`" %dismtarget% /Enable-Feature:SMB1Protocol |
| 228 | +%_dism2%:`"!_cabdir!`" %dismtarget% /Enable-Feature:TFTP |
| 229 | +%_dism2%:`"!_cabdir!`" %dismtarget% /Enable-Feature:TelnetClient |
| 230 | +
|
| 231 | +echo. |
| 232 | +echo ============================================================ |
| 233 | +echo Adding Features on Demands... |
| 234 | +echo ============================================================ |
| 235 | +
|
| 236 | +echo current dir: %cd% |
| 237 | +
|
| 238 | +if exist `"%~dp0fod\Miracast\update.mum`" ( |
| 239 | + %_dism2%:`"!_cabdir!`" %dismtarget% /Add-Package /PackagePath:`"%~dp0fod\Miracast\update.mum`" |
| 240 | + %_dism2%:`"!_cabdir!`" %dismtarget% /Add-Package /PackagePath:`"%~dp0fod\MiracastLP\update.mum`" |
| 241 | +) |
| 242 | +if exist `"%~dp0fod\iexplorer\update.mum`" ( |
| 243 | + %_dism2%:`"!_cabdir!`" %dismtarget% /Add-Package /PackagePath:`"%~dp0fod\iexplorer\update.mum`" |
| 244 | +) |
| 245 | +
|
| 246 | +echo. |
| 247 | +echo ============================================================ |
| 248 | +echo Updating Microsoft Store... |
| 249 | +echo ============================================================ |
| 250 | +
|
| 251 | +$MSStoreScript |
| 252 | +
|
| 253 | +exit /b |
| 254 | +
|
| 255 | +:Add-ProvisionedAppxPackage |
| 256 | +echo installing - %~n1 |
| 257 | +%_dism2%:`"!_cabdir!`" %dismtarget% /Add-ProvisionedAppxPackage /PackagePath:`"%~1`" /SkipLicense /Region:all |
| 258 | +goto :EOF |
| 259 | +" | Out-File -FilePath ".\hook.cmd" |
| 260 | + |
| 261 | +# execute W10UI script |
| 262 | +.\W10UI.cmd |
| 263 | + |
| 264 | +# upload to cloud |
| 265 | +Get-ChildItem -Path "./*.iso" -File | ForEach-Object { |
| 266 | + .\bin\rclone.exe copy $_.FullName "odb:/Share/Xiaoran Studio/System/Nightly" --progress |
| 267 | +} |
0 commit comments