有趣生活

当前位置:首页>科技>五分钟学会封装系统便捷的系统封装批处理

五分钟学会封装系统便捷的系统封装批处理

发布时间:2026-07-21阅读(1)

导读功能这段时间总在反复封装系统,输入命令实在太累了,编写这个脚本,只需要按照提示输入【】中的指令,最后按d即可。轻松不少,分享给大伙。本脚本实现的功能如下图:....功能

这段时间总在反复封装系统,输入命令实在太累了,编写这个脚本,只需要按照提示输入【】中的指令,最后按d即可。轻松不少,分享给大伙。

本脚本实现的功能如下图:

主菜单

捕获镜像

安装镜像

将镜像部署自动化

使用方法

建立一个专用目录,如osdiy

在目录下新建一个osdiy.bat批处理文件,把本文的代码复制到其中。

下载驱动总裁万能网卡版,放到osdiy目录下,目录名应该是 DrvCeonw 。你也可以使用其他版本,更改应答文件中的路径即可。

将你的自动应答文件命名为unattend.xml,放到osdiy目录下。如果没有自动应答文件,可以拷贝超级大网管的《系统封装》一文中的内容。

将osdiy.bat文件开头systemtype和softs的值更改为你自己的。

如果你有自己的dism,复制到osdiy目录下,脚本便会自动使用。如果没有,又想制作所需版本,可以看超级大网管《Dism命令常用方法》一文。(dism的版本很重要哦,否则可能出现镜像集成到iso文件中部署时出错)

下面就可以直接执行该文件啦。

代码

@echo offsetlocal enabledelayedexpansioncd /d %~dp0rem 系统类型,如果你改变系统类型,改这里即可set systemtype=windows_10_enterpriserem 集成的软件列表,也传递给镜像的name参数。通常你只需要改变softs和systemtype两个值即可。set softs=WPS_Cad2016_T20rem 系统名称set systemname=%systemtype%rem 审核模式使用的镜像文件名添加_audit以区分其他镜像set auditimagefile=%systemname%_auditset oobeimagefile=%systemname%rem 镜像挂载路径set mountpath=%~dp0mount:topcommandclsecho ***********************************echo 超级大网管@索强科技echo ***********************************echo.echo 捕获镜像【c】安装镜像【i】自动化镜像【d】退出【q】echo.set /p tcommand=请选择操作:if "%tcommand%" == "" goto topcommandif /i "%tcommand%" == "q" goto enddiyif /I "%tcommand%" == "i" goto installimageif /I "%tcommand%" == "c" goto captureif /I "%tcommand%" == "d" goto autoimage:installimageclsset scommand=""if "%imageindex%" == "" set imageindex=1if /i "%imagetype%"=="" (set imagefile=%oobeimagefile%_%softs%.wim)echo.echo 镜像文件【f】:%imagefile% ;镜像索引【i】:%imageindex%;系统盘【t】:%systemp%;启动盘 【b】:%bootp%echo 开始【d】 退出【q】echo.set /p scommand=请选择操作:if /I "%scommand%" == "q" goto topcommandif /I "%scommand%" == "f" (goto selectimagetype)if /I "%scommand%" == "t" (set /p systemp=请输入系统盘符,不需要冒号:goto installimage)if /I "%scommand%" == "b" (set /p bootp=请输入启动盘符,不需要冒号:goto installimage)if /I "%scommand%" == "i" (set /p imageindex=请输入索引:goto installimage)if /I "%scommand%" == "d" (if /I not "%systemp%" == "" (format %systemp%: /Q /FS:NTFS /Yif ERRORLEVEL 1 (pausegoto installimage)cd /d %~dp0if exist "dism" ( cd dism ) dism /Apply-Image /ImageFile:%~dp0%imagefile% /Index:%imageindex% /ApplyDir:%systemp%:if ERRORLEVEL 1 (pausegoto installimage)cd /d %~dp0) else (goto installimage)if /I not "%bootp%" == "" (format %bootp%: /Q /FS:FAT32 /Yif ERRORLEVEL 1 (pausegoto installimage)%systemp%:\windows\system32\bcdboot %systemp%:\windows /pif ERRORLEVEL 1 (pausegoto installimage))pausegoto topcommand) else (goto installimage):captureclsset scommand=""if /i "%imagetype%"=="" (set imagefile=%oobeimagefile%_%softs%.wim)echo.echo 镜像文件【f】:%imagefile% ; 目标盘【t】:%systemp%; echo 开始【d】 退出【q】echo.set /p scommand=请选择操作:if /I "%scommand%" == "q" goto topcommandif /I "%scommand%" == "f" (goto selectimagetype)if /I "%scommand%" == "t" (set /p systemp=请输入目标盘:goto capture)if /I "%scommand%" == "d" (if /I not "%systemp%" == "" (cd /d %~dp0if exist "dism" ( cd dism ) dism /capture-Image /ImageFile:%~dp0%imagefile% /capturedir:%systemp%: /compress:max /name:"%softs%"if ERRORLEVEL 1 (pausegoto capture)cd /d %~dp0goto topcommand) else (goto capture))else (goto capture):autoimageclsset scommand=""if /i "%imagetype%"=="" (set imagefile=%oobeimagefile%_%softs%.wim)if "%imageindex%" == "" set imageindex=1if "%unattendfile%" == "" set unattendfile=unattend.xmlecho.echo 镜像文件【f】:%imagefile% ;镜像索引【i】:%imageindex%;应答文件【a】:%unattendfile%;echo 开始【d】 退出【q】echo.set /p scommand=请选择操作:if /I "%scommand%" == "q" goto topcommandif /I "%scommand%" == "f" (goto selectimagetype)if /I "%scommand%" == "a" (set /p unattendfile=请输入应答文件名:goto autoimage)if /I "%scommand%" == "i" (set /p imageindex=请输入索引:goto autoimage)if /I "%scommand%" == "d" (cd /d %~dp0if not exist %mountpath% mkdir %mountpath%if exist "dism" ( cd dism ) dism /mount-Image /ImageFile:"%~dp0%imagefile%" /mountdir:%mountpath% /index:%imageindex%if ERRORLEVEL 1 (pausegoto autoimage)cd /d %~dp0rem 拷贝自动应答文件copy %unattendfile% %mountpath%\windows\Panther\unattend.xml /Yrem 拷贝驱动xcopy DrvCeonw %mountpath%\windows\DrvCeonw\ /E /Yif exist "dism" ( cd dism ) dism /unmount-Image /mountdir:%mountpath% /commitif ERRORLEVEL 1 (pausegoto autoimage)goto topcommand) else (goto autoimage):selectimagetypeecho 审核模式镜像【a】全新体验镜像【o】set /p imagetype=请请选择镜像类型:if /I "%imagetype%"=="a" (set imagefile=%auditimagefile%_%softs%.wim)else (set imagefile=%oobeimagefile%_%softs%.wim)if /I "%tcommand%" == "i" goto installimageif /I "%tcommand%" == "c" goto captureif /I "%tcommand%" == "d" goto autoimage:enddiy

Copyright © 2024 有趣生活 All Rights Reserve吉ICP备19000289号-5 TXT地图HTML地图XML地图