这是系统封装批处理,我断章取义了。
if !OpChoice!==14 (
echo 查找同目录(及子目录)下自动应答文件,如果一个都没有,那就不要试了。
echo 本工具包提供的自动应答文件分64位和32位两种,通用版仅仅实现跳过oobe过程。
set /a NumUntitled=0
set /a a=0
set NameUntitled=null
dir %~dp0*.xml /b /s >%~dp0fAppUntitled.txt
echo 查找到%~dp0目录下所有自动应答文件如下表
echo -----------------------------------------------------
for /f "usebackq delims=" %%i in (%~dp0fAppUntitled.txt) do ( set /a a+=1&&echo 应答文件:!a! %%i)
if !a!==0 echo 根本就没有一个自动应答文件,那封装也没什么意思了,准备退出!&&goto End
echo.
set /p NumUntitled=请认真选择应答文件序号,不带冒号----
set /a a=0
for /f "usebackq delims=" %%i in (%~dp0fAppUntitled.txt) do (
set /a a+=1
if !NumUntitled!==!a! echo 你选择的应答文件是:%%i
)
set bGoSysprep=y
set /p bGoSysprep=最后请确认现在可以开始封装了吗?默认是,直接回车,如果算了,请输入小写n----
if not !bGoSysprep!==n (
echo 正在帮您清除系统垃圾文件,请稍等......
::删除补丁备份目录
rd %windir%\$hf_mig$ /Q /S
::删除系统盘Office安装临时文件
rd /s /q %systemdrive%\msocache
dir /ad /b /s %windir%\$NtUninstall* >%~dp0Del_rd.txt
dir /ad /b /s %windir%\SoftwareDistribution\Download>>%~dp0Del_rd.txt
for /f %%i in (%~dp0Del_rd.txt ) do ( rd "%%i" /s /q )
del %~dp0Del_rd.txt /f /q
::删除补丁安装记录内容(下面的del /f /s /q %systemdrive%\*.log已经包含删除此类文件)
del %windir%\KB*.log /f /q
::删除系统盘目录下临时文件
del /f /s /q %windir%\*.tmp
::删除系统盘目录下临时文件
del /f /s /q %windir%\*._mp
::删除系统盘目录下日志文件
del /f /s /q %windir%\*.log
::删除系统盘目录下GID文件
del /f /s /q %windir%\*.gid
::删除系统目录下scandisk(磁盘扫描)留下的无用文件
del /f /s /q %windir%\*.chk
::删除系统目录下old文件
del /f /s /q %windir%\*.old
::删除回收站的无用文件
del /f /s /q %windir%\recycled\*.*
::删除系统目录下备份文件
del /f /s /q %windir%\*.bak
::删除系统维护等操作产生的临时文件
rd /s /q %windir%\temp md %windir%\temp
::删除当前用户的COOKIE(IE)
del /f /q %userprofile%\cookies\*.*
::删除internet临时文件
del /f /s /q "%userprofile%\local settings\temporary internet files\*.*"
::删除当前用户日常操作临时文件
del /f /s /q "%userprofile%\local settings\temp\*.*"
copy %systemdrive%\Users\%username%\Favorites\*.* %systemdrive%\Users\Default\Favorites
dir %~dp0Desk*.bat /b /s >%~dp0fTmp.txt
dir %~dp0Driver*.bat /b /s >>%~dp0fTmp.txt
for /f %%i in (%~dp0fTmp.txt) do ( copy %%i %windir%\system32 )
set /a a=0
for /f "usebackq delims=" %%i in (%~dp0fAppUntitled.txt) do (
set /a a+=1
if !a!==!NumUntitled! %windir%\system32\sysprep\sysprep.exe /oobe /generalize /shutdown /unattend:%%i
)
)