update AppData.tmpl

This commit is contained in:
slore 2021-06-06 01:51:01 +08:00
parent 78ce08cf6c
commit 919cf8ba32
12 changed files with 257 additions and 23 deletions

View File

@ -0,0 +1,57 @@
Const OpenAsASCII = 0
Const OpenAsUnicode = -1
Const FailIfExist = 0
Const OverwriteIfExist = -1
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Dim FSO, WshShell, regEx
Dim objkeepdict, f
Set WshShell = Wscript.CreateObject("Wscript.Shell")
Set FSO = CreateObject("Scripting.FileSystemObject")
Set objkeepdict = CreateObject("Scripting.Dictionary")
Set f = FSO.OpenTextFile("_wimsyslist.txt", ForReading, FailIfNotExist)
wimorgfiles = f.ReadAll()
f.Close()
Set regEx = New RegExp
regEx.Pattern = "\\Windows\\System32\\.+\\.+\r\n"
regEx.IgnoreCase = True
regEx.Global = True
wimorgfiles = regEx.Replace(wimorgfiles, "")
wimorgfiles = Mid(wimorgfiles, 20) ' SKip \Windows\System32
Set f = FSO.OpenTextFile("SysWhiteList.txt", ForReading, FailIfNotExist)
keepfiles = f.ReadAll()
f.Close()
Dim i, lines
lines = Split(keepfiles, vbCrLf)
For i = 0 To UBound(lines) - 1:objkeepdict.Add lines(i), 1:Next
lines = Split(wimorgfiles, vbCrLf)
Dim n
ReDim remove_files(UBound(lines))
n = 0
For i = 0 To UBound(lines) - 1
If Mid(Right(lines(i), 4), 1, 1) = "." Then
If Not objkeepdict.Exists(lines(i)) Then
remove_files(n) = "delete --force " & lines(i)
n = n + 1
End If
End If
Next
ReDim Preserve remove_files(n)
Set f = FSO.OpenTextFile("_wimsyslist.txt", ForWriting, OverwriteIfExist)
f.Write(Join(remove_files, vbCrLf))
f.Close()
WSH.Quit(0)

View File

@ -0,0 +1,46 @@
echo 可以使用wimlib命令对WB_BASE_PATH文件进行预处理
echo 比如精简文件,添加替换文件和注册表。
sleep 1
rem set WB_
rem 使用白名单精简
if not exist "SysWhiteList.txt" goto :EOF
pushd "%~dp0"
wimlib-imagex dir "%WB_BASE_PATH%" %WB_BASE_INDEX% --path=\Windows\System32\ > _wimsyslist.txt
echo %time%
call UpdateWimWithWhiteList.vbs
wimlib-imagex update "%WB_BASE_PATH%" %WB_BASE_INDEX% < _wimsyslist.txt
popd
echo %time%
goto :EOF
:SAMPLE_INFO
WB_ROOT=E:\WimBuilder2
WB_HOST_LANG=zh-CN
WB_ARCH=x64
WB_PROJECT=WIN10XPE
WB_PROJECT_PATH=E:\WimBuilder2\Projects\WIN10XPE
WB_SRC=H:\sources\install.wim
WB_SRC_FOLDER=H:
WB_SRC_INDEX=1
WB_BASE=winre.wim
WB_BASE_PATH=Z:\WimBuilder2\_Factory_\target\WIN10XPE\winre.wim
WB_BASE_INDEX=1
WB_PE_ARCH=x64
WB_PE_BUILD=1
WB_PE_LANG=zh-CN
WB_PE_VER=10.0.21390
WB_TMP_PATH=Z:\WimBuilder2\_Factory_\tmp\WIN10XPE
WB_USER_PROJECT_PATH=E:\WimBuilder2\AppData.link\Projects\WIN10XPE
WB_X_DRIVE=X:
goto :EOF

View File

@ -0,0 +1,12 @@
echo 自定义挂载WIM映像的脚本
call WIM_Mounter "%_WB_PE_WIM%" %WB_BASE_INDEX% "%_WB_MNT_DIR%" base_wim_mounted
if not "%base_wim_mounted%"=="1" (
call :cecho ERROR "mount base wim file failed."
call _Cleanup
pause
exit 1
)
rem 禁止映射挂载目录为X驱动器
rem set NO_X_SUBST=1

View File

@ -0,0 +1,17 @@
echo 可在此脚本中编写代码在保存boot.wim变动前对boot.wim进行最后的修改。
rem 替换注册表 HIVE 文件
call :FULLREG DEFAULT
call :FULLREG SOFTWARE
call :FULLREG SYSTEM
call :FULLREG COMPONENTS
call :FULLREG DRIVERS
goto :EOF
:FULLREG
if exist "%~dp0%1" (
xcopy /E /Y "%~dp0%1" "%X%\Windows\System32\Config\"
)
goto :EOF

View File

@ -0,0 +1,4 @@
echo 自定义保存WIM映像的脚本
call _Cleanup 0
call WIM_Exporter "%_WB_PE_WIM%"

View File

@ -0,0 +1,4 @@
echo Custom script to commit the WIM file.
call _Cleanup 0
call WIM_Exporter "%_WB_PE_WIM%"

View File

@ -0,0 +1,41 @@
if "x%~1"=="x" goto :EOF
call :%1 "%~2"
goto :EOF
rem ===================================
:PreISO
set WB_ISO_
goto :EOF
rem ===================================
:MakeISO
if not "x%opt[iso.attended_boot]%"=="xtrue" (
set EFI_BIN=efisys_noprompt.bin
ren "%ISO_PATH%\boot\bootfix.bin" bootfix.bin.bak
) else (
ren "%ISO_PATH%\boot\bootfix.bin.bak" bootfix.bin
)
if "x%opt[iso.x_exFAT]%"=="xtrue" (
xcopy /d /c /y "%WB_ROOT%\Projects\%WB_PROJECT%\zz-ISO\boot.sdi" "%ISO_PATH%\boot\boot.sdi"
) else (
xcopy /E /Y "%WB_SRC_FOLDER%\boot\boot.sdi" "%ISO_PATH%\boot\boot.sdi"
)
if not "x%opt[iso.edit_bcd]%"=="xtrue" goto :EOF
set BCD_BOOTMENUPOLICY=Standard
if "x%opt[iso.loading_progress]%"=="xtrue" (
set BCD_BOOTMENUPOLICY=Legacy
)
"%SystemRoot%\sysnative\cmd.exe" /c bcdedit.exe /store "%ISO_PATH%\boot\bcd" /set {default} bootmenupolicy %BCD_BOOTMENUPOLICY%
del /a "%ISO_PATH%\boot\bcd.LOG*"
goto :EOF
rem ===================================
:PostISO
if "x%~1"=="x" echo Failed to make ISO file.&&goto :EOF
echo %WB_ISO_PATH%
goto :EOF

View File

@ -0,0 +1,12 @@
echo Custom script to mount the WIM file.
call WIM_Mounter "%_WB_PE_WIM%" %WB_BASE_INDEX% "%_WB_MNT_DIR%" base_wim_mounted
if not "%base_wim_mounted%"=="1" (
call :cecho ERROR "mount base wim file failed."
call _Cleanup
pause
exit 1
)
rem Disable mapping mounted directory to the X drive
rem set NO_X_SUBST=1

View File

@ -0,0 +1,19 @@
rem echo the final process before commiting the boot.wim
rem use prepared HIVE files
call :FULLREG DEFAULT
call :FULLREG SOFTWARE
call :FULLREG SYSTEM
call :FULLREG COMPONENTS
call :FULLREG DRIVERS
goto :EOF
:FULLREG
if exist "%~dp0%1" (
xcopy /E /Y "%~dp0%1" "%X%\Windows\System32\Config\"
)
goto :EOF

View File

@ -0,0 +1,45 @@
echo Do preprocess on boot.wim (%WB_BASE_PATH%).
echo Slim it, or add files and replace the registry HIVEs.
sleep 5
rem set WB_
rem slim boot.wim with whitelist
if not exist "SysWhiteList.txt" goto :EOF
pushd "%~dp0"
wimlib-imagex dir "%WB_BASE_PATH%" %WB_BASE_INDEX% --path=\Windows\System32\ > _wimsyslist.txt
echo %time%
call UpdateWimWithWhiteList.vbs
wimlib-imagex update "%WB_BASE_PATH%" %WB_BASE_INDEX% < _wimsyslist.txt
popd
echo %time%
goto :EOF
:SAMPLE_INFO
WB_ROOT=E:\WimBuilder2
WB_HOST_LANG=zh-CN
WB_ARCH=x64
WB_PROJECT=WIN10XPE
WB_PROJECT_PATH=E:\WimBuilder2\Projects\WIN10XPE
WB_SRC=H:\sources\install.wim
WB_SRC_FOLDER=H:
WB_SRC_INDEX=1
WB_BASE=winre.wim
WB_BASE_PATH=Z:\WimBuilder2\_Factory_\target\WIN10XPE\winre.wim
WB_BASE_INDEX=1
WB_PE_ARCH=x64
WB_PE_BUILD=1
WB_PE_LANG=zh-CN
WB_PE_VER=10.0.21390
WB_TMP_PATH=Z:\WimBuilder2\_Factory_\tmp\WIN10XPE
WB_USER_PROJECT_PATH=E:\WimBuilder2\AppData.link\Projects\WIN10XPE
WB_X_DRIVE=X:
goto :EOF

View File

@ -1,22 +0,0 @@
rem Call this by Projects\[ProjectName]\prepare.bat
if "x%~1"=="x" goto :EOF
call %1
goto :EOF
:BEFORE_WIM_BUILD
rem ===================================
rem ===================================
goto :EOF
:BEFORE_WIM_MOUNT
rem ===================================
rem ===================================
goto :EOF
:BEFORE_HIVE_LOAD
rem ===================================
rem ===================================
goto :EOF

View File

@ -1 +0,0 @@
rem echo the final process before commiting the boot.wim