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

功能

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

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

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

主菜单

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

捕获镜像

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

安装镜像

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

将镜像部署自动化

使用方法

建立一个专用目录,如osdiy

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

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

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

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

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

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

代码

@echo off setlocal enabledelayedexpansion cd /d %~dp0 rem 系统类型,如果你改变系统类型,改这里即可 set systemtype=windows_10_enterprise rem 集成的软件列表,也传递给镜像的name参数。通常你只需要改变softs和systemtype两个值即可。 set softs=WPS_Cad2016_T20 rem 系统名称 set systemname=%systemtype% rem 审核模式使用的镜像文件名添加_audit以区分其他镜像 set auditimagefile=%systemname%_audit set oobeimagefile=%systemname% rem 镜像挂载路径 set mountpath=%~dp0mount :topcommand cls echo *********************************** echo 超级大网管@索强科技 echo *********************************** echo. echo 捕获镜像【c】 安装镜像【i】 自动化镜像【d】 退出【q】 echo. set /p tcommand=请选择操作: if "%tcommand%" == "" goto topcommand if /i "%tcommand%" == "q" goto enddiy if /I "%tcommand%" == "i" goto installimage if /I "%tcommand%" == "c" goto capture if /I "%tcommand%" == "d" goto autoimage :installimage cls set scommand="" if "%imageindex%" == "" set imageindex=1 if /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 topcommand if /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 /Y if ERRORLEVEL 1 ( pause goto installimage ) cd /d %~dp0 if exist "dism" ( cd dism ) dism /Apply-Image /ImageFile:%~dp0%imagefile% /Index:%imageindex% /ApplyDir:%systemp%: if ERRORLEVEL 1 ( pause goto installimage ) cd /d %~dp0 ) else ( goto installimage ) if /I not "%bootp%" == "" ( format %bootp%: /Q /FS:FAT32 /Y if ERRORLEVEL 1 ( pause goto installimage ) %systemp%:\windows\system32\bcdboot %systemp%:\windows /p if ERRORLEVEL 1 ( pause goto installimage ) ) pause goto topcommand ) else ( goto installimage ) :capture cls set 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 topcommand if /I "%scommand%" == "f" ( goto selectimagetype ) if /I "%scommand%" == "t" ( set /p systemp=请输入目标盘: goto capture ) if /I "%scommand%" == "d" ( if /I not "%systemp%" == "" ( cd /d %~dp0 if exist "dism" ( cd dism ) dism /capture-Image /ImageFile:%~dp0%imagefile% /capturedir:%systemp%: /compress:max /name:"%softs%" if ERRORLEVEL 1 ( pause goto capture ) cd /d %~dp0 goto topcommand ) else ( goto capture ) )else ( goto capture ) :autoimage cls set scommand="" if /i "%imagetype%"=="" (set imagefile=%oobeimagefile%_%softs%.wim) if "%imageindex%" == "" set imageindex=1 if "%unattendfile%" == "" set unattendfile=unattend.xml echo. echo 镜像文件【f】:%imagefile% ;镜像索引【i】:%imageindex%;应答文件【a】:%unattendfile%; echo 开始【d】 退出【q】 echo. set /p scommand=请选择操作: if /I "%scommand%" == "q" goto topcommand if /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 %~dp0 if not exist %mountpath% mkdir %mountpath% if exist "dism" ( cd dism ) dism /mount-Image /ImageFile:"%~dp0%imagefile%" /mountdir:%mountpath% /index:%imageindex% if ERRORLEVEL 1 ( pause goto autoimage ) cd /d %~dp0 rem 拷贝自动应答文件 copy %unattendfile% %mountpath%\windows\Panther\unattend.xml /Y rem 拷贝驱动 xcopy DrvCeonw %mountpath%\windows\DrvCeonw\ /E /Y if exist "dism" ( cd dism ) dism /unmount-Image /mountdir:%mountpath% /commit if ERRORLEVEL 1 ( pause goto autoimage ) goto topcommand ) else ( goto autoimage ) :selectimagetype echo 审核模式镜像【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 installimage if /I "%tcommand%" == "c" goto capture if /I "%tcommand%" == "d" goto autoimage :enddiy

,

免责声明:本文仅代表文章作者的个人观点,与本站无关。其原创性、真实性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容文字的真实性、完整性和原创性本站不作任何保证或承诺,请读者仅作参考,并自行核实相关内容。文章投诉邮箱:anhduc.ph@yahoo.com

    分享
    投诉
    首页